• 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: Best practices for creating and comparing lists of text?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Best practices for creating and comparing lists of text?


  • Subject: Re: Best practices for creating and comparing lists of text?
  • From: Christopher Nebel <email@hidden>
  • Date: Thu, 15 Dec 2005 19:27:17 -0800

On Dec 15, 2005, at 8:47 AM, Brian Arnold wrote:

I am working on two AppleScript scripting problems with text and lists that seem to be related. ... Here is some sample code for both problems. ...

set AppleScript's text item delimiters to {"="}
set currentLine to currentLine as list
set AppleScript's text item delimiters to savedTextItemDelimiters

              

set moduleName to item 1 of currentLine-- DOESN’T WORK
set libraryName to item 2 of currentLine-- DOESN’T WORK

The key problem is that "as list" doesn't do what you think it does.  While it's true that "some_list as string" will join the list items together using the "text item delimiters" value, "some_string as list" does not split the string apart -- it merely makes a one-item list with that string value.  What you want to say is "every text item of some_string".  If your delimiter is return, then it's often more correct -- not to mention shorter -- to say "every paragraph of some_string" instead, because "every paragraph" is line-ending-agnostic -- it treats Mac-, Windows-, and Unix-style line breaks equivalently.

Incidentally, the technical term for your second problem, identifying the items that are in one list or the other, but not both, is "symmetric set difference".  This may help you track down a suitable algorithm.


--Chris Nebel
AppleScript and Automator Engineering

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Best practices for creating and comparing lists of text? (From: Brian Arnold <email@hidden>)

  • Prev by Date: Re: Set hours of date = stack overflow error on 10.3.9?
  • Next by Date: Re: Loading Print Styles in Quark?
  • Previous by thread: Best practices for creating and comparing lists of text?
  • Next by thread: Re: Best practices for creating and comparing lists of text?
  • Index(es):
    • Date
    • Thread