Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Cojust

macrumors newbie
Original poster
Jan 27, 2011
4
0
Little help here, i use text items quite a fair bit, however, i have a slight problem. If i have a set amount of text items a variable will contain, for example, 3, this would work fine
Code:
set {var1,var2,var3} to text items of variable
However, if i do not know exactly how many variables, eg just 2 text items are in the variable, it throws an error. What i use now to solve that is
Code:
try
set var1 to text item 1 of variable
on error
set var1 to ""
end
Is there a more efficient way to do it?
 
You can try something like this:
Code:
if (count of text items of variable) ≥ 1 then
    set var1 to text item 1 of variable
else
    set var1 to missing value
end if
 
My bad. What i wanted to do is as
Code:
try
set var1 to text item 1 of variable
on error
set var1 to ""
end
, but more efficiently(if there is such a method)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.