Why, oh why, does a list element that is, in fact, a string not compare as a string? Funny thing is, under some conditions it does!
______________________________________________________________________
Hey Rob,
I agree with Jon. It's not that mysterious - BUT — its pretty shocking when you first run into it.
Here's a little better way to visualize your data:
-------------------------------------------------------------------------------------------
property a_list : {"a", "b", "c"} repeat with an_item in a_list return an_item #### Run and see then comment-out this line an_item as text #### This statement de-references an_item return result end repeat
-------------------------------------------------------------------------------------------
property a_list : {"a", "b", "c"} repeat with an_item in a_list set a to an_item set b to an_item as text return {a, b} end repeat
-------------------------------------------------------------------------------------------
property a_list : {"a", "b", "c"} set _cntr to 0
repeat with an_item in a_list set _cntr to _cntr + 1
if _cntr = 2 then #### Change to see 1, 2 or 3 set a to an_item set b to an_item as text return {a, b} end if
end repeat
-------------------------------------------------------------------------------------------
Better yet is to buy Script Debugger, but you'll have to be willing to part with some bucks. With SD you can step though a script and visualize everything as it occurs. You can also set break-points to pause execution at a specific point (or points). I bought v1.0 about 1996 and have upgraded ever since; it has saved me endless headaches while wrestling with Applescript.
You can find some information on this repeat-in-list format on p. 204 of the Applescript Language Guide. [ Web][ PDF]
Be sure to look over the debugging stuff if you haven't.
One of the gotchas is that if you use log <value> on a referenced list item with will get de-referenced.
Confusing.
To see it properly you need to return it/them as I've done above.
-- Best Regards, Chris
|