• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Strings as list items don't always compare as strings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Strings as list items don't always compare as strings


  • Subject: Re: Strings as list items don't always compare as strings
  • From: Christopher Stone <email@hidden>
  • Date: Sat, 23 Mar 2013 02:12:15 -0500

On Mar 23, 2013, at 00:42, Rob Lewis <email@hidden> wrote:
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

 _______________________________________________
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

References: 
 >Strings as list items don't always compare as strings (From: Rob Lewis <email@hidden>)

  • Prev by Date: Re: Strings as list items don't always compare as strings
  • Next by Date: Re: Strings as list items don't always compare as strings
  • Previous by thread: Re: Strings as list items don't always compare as strings
  • Next by thread: Ping Script
  • Index(es):
    • Date
    • Thread