RE: Faster List Checking
RE: Faster List Checking
- Subject: RE: Faster List Checking
- From: "Frank W. Walker" <email@hidden>
- Date: Wed, 28 May 2003 16:03:46 -0400
- Thread-topic: Faster List Checking
Sorry, I made an error in my description. Since I wanted the "lists" to exist even after script termination/ computer shut-down, what I did was declare two "properties", thusly:
property logolist : ""
property errorlist : ""
I then used the text item delimiter ", " to coerce these properties into functioning as "lists".
Sorry for the confusion, and thanks for the response.
Frank
>
----------
>
From: Gary Lists
>
Sent: Wednesday, May 28, 2003 3:29 PM
>
To: AppleScript Users
>
Subject: Re: Faster List Checking
>
>
On or about 5/28/03 2:15 PM, Frank W. Walker wrote:
>
>
> The recent discussion about lists makes me wonder if I could improve the speed
>
> of my latest script.
>
> In my script, there are two lists, text delimited by ", ":
>
> "errorlist" contains known instances of missing items (graphics).
>
> "logolist" contains all items (graphics) which have previously been found.
>
>
>
> The following lines check the list "errorlist" for the text item contained in
>
> the variable "graphic":
>
>
>
> set AppleScript's text item delimiters to {", "}
>
> repeat with i from 1 to (count text items in errorlist) --checks error list
>
> for current logo name
>
> if text item i of errorlist = graphic then
>
> set knownerror to "YES"
>
> end if
>
> end repeat
>
> set AppleScript's text item delimiters to {""}
>
>
>
>
>
> The next part checks the list "logolist" for the text item contained in the
>
> variable "graphic".
>
> If it finds the text item, it sets the variable "templatename" to a certain
>
> string.
>
>
>
>
>
> set AppleScript's text item delimiters to {", "}
>
> repeat with i from 1 to (count text items in logolist)
>
> if text item i of logolist = graphic then --checks logolist for previous
>
> use of graphic
>
> set templatename to "LOGO" & graphic
>
> exit repeat
>
> end if
>
> end repeat
>
> set AppleScript's text item delimiters to {""}
>
>
>
>
>
> Can I make these faster?
>
>
>
> TIA
>
> Frank
>
>
Frank,
>
>
I'm going to have a go at a few comments here. I am sure that others will
>
also, and that may help with speed and such (I mentioned the script object
>
list 'trick' earlier, so I won't repeat.)
>
>
Since I am "past beginner but no pro" perhaps my reply will help me a well
>
(or at least any correction from others if I err will. ;)
>
>
1. Since you use a delimiter of ", " in one instance, that makes me think
>
that you must have data in the form:
>
>
"something, something, something, something" -- as a string
>
>
This is perhaps a real slow-down.
>
>
If you just "flip your list/string" thinking (see number 2. below), you'll
>
be to a more conventional way of doing things, and therefore maybe a faster
>
way.
>
>
Get your DATA into a list, like:
>
>
{"something", "something", "something"}
>
>
and then you don't even need the text item delimiters to "break" the big
>
string into small pieces.
>
>
Instead, you can just use:
>
>
if item i of logolist = graphic
>
>
and not: if text item i of logolist = graphic
>
>
>
See, a text item delimiter "delimits a text item" (not being facetious,
>
just reminding you that the language is the clue.)
>
>
>
You want to be "delimiting" (so to speak) a list. Yes, the list in AS uses
>
a ", " to separate its items, but you just refer to item 1, item 2, item x
>
and the "delimiting" is done for you.
>
>
>
I think the text item delimiters is the slow way.
>
>
>
2. I don't know why you are setting the delimiters to a list, even given
>
that your data is (probably) a big text string. This is not needed.
>
(Whether it adds time of any human-noticeable duration I doubt in this
>
instance.) There is no need to coerce a text item delimiter to a list. (I
>
don't even know why that works, except AS is smart enough to just ignore the
>
incident and move along.) Just say this:
>
>
set AppleScript's text item delimiters to "" -- or whatever string>
>
>
>
>
Basically, remove the AppleScript's text item delimiter lines, change
>
instances of 'text item i' to 'item i', make sure your errorlist and
>
logolist are really _lists_ ( {"graphic","graphic","graphic",...} ) and
>
see what that does.
>
>
>
Making those changes shortens your code for sure and I think will make these
>
processes faster.
>
>
>
HTH
>
--
>
Gary
>
>
Incoming replies are auto-deleted.
>
Please post directly to the list or newsgroup.
>
_______________________________________________
>
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.
_______________________________________________
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.