Re: Strings as list items don't always compare as strings
Re: Strings as list items don't always compare as strings
- Subject: Re: Strings as list items don't always compare as strings
- From: Jon Pugh <email@hidden>
- Date: Fri, 22 Mar 2013 22:55:15 -0700
On Mar 22, 2013, at 10:42 PM, Rob Lewis wrote:
> This:
>
> property a_list: {"a"}
> repeat with an_item in a_list
> display dialog an_item --displays "a" (without quotes)
> an_item is "a" --FALSE!
> an_item as text is "a" --TRUE
> end repeat
>
> 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!
>
> One of AppleScript's enduring mysteries.
>
> Explanation greatly appreciated.
property a_list : {"a"}
repeat with an_item in a_list
display dialog an_item --displays "a" (without quotes)
contents of an_item is "a" --FALSE!
end repeat
In this scenario, the variable of a repeat loop, an_item, is a reference, specifically “item 1 of a_list”. Realizing this will make your life so much better. You can get the contents of a reference to do what you expect.
It’s not that mysterious.
Jon
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden