• 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: Faster List Checking
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Faster List Checking


  • Subject: Re: Faster List Checking
  • From: Tim Mansour <email@hidden>
  • Date: Thu, 29 May 2003 09:36:44 +1000

Since you only care if graphic appears in the errorList, you can say:
if errorList contains graphic then
set knownerror to "YES"
end if
This eliminates the need to delimit the string, walk the loop, etc., etc.

There can be problems with this method, Andrew, brought about because we're dealing with text strings and the 'words' aren't clearly delimited as they are with a list. For instance:

set errorList to "newthing, item, foo"
set graphic to "thing"
set knownerror to (errorList contains graphic)
result --> true

Whenever you're doing searches like this within text, it becomes necessary to include delimiters to make sure you don't get substrings matching (even if it seems unlikely, take it from me that it's a bitch to debug when it happens!). For instance:

set delim to ", "
set errorList to delim & "newthing, item, foo" & delim

set graphic to delim & "thing" & delim
set knownerror to (errorList contains graphic)
result --> false

set graphic to delim & "newthing" & delim
set knownerror to (errorList contains graphic)
result --> true

Of course, you need to be careful about what delimiter you use, as it can't be contained within one of the 'words'. Of course, this also would be the case if you relied on lists and AppleScript's text item delimiters.

--
Tim Mansour <email@hidden>
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: Tex-Edit: crashes selecting to EOF
  • Next by Date: Re: applescripted login
  • Previous by thread: RE: Faster List Checking
  • Next by thread: RE: Faster List Checking
  • Index(es):
    • Date
    • Thread