optimizing object filtering (multiple search/replace in QuarkXPress)
optimizing object filtering (multiple search/replace in QuarkXPress)
- Subject: optimizing object filtering (multiple search/replace in QuarkXPress)
- From: John Hawkinson <email@hidden>
- Date: Wed, 26 May 2004 20:55:52 -0400 (EDT)
- Resent-date: Wed, 26 May 2004 22:14:49 -0400
- Resent-from: email@hidden
- Resent-message-id: <email@hidden>
- Resent-to: email@hidden
Hi. I'm fairly new to AppleScript, so I apologize if there's somewhere
I should have looked to address this.
I have an AppleScript that performs several consecutive
search-and-replaces in QuarkXPress 6, and I would like to speed it
up. At present, it does:
tell document 1
set every word of every story whose (contents="MM") to mmexpand
set every word of every story whose (contents="DD") to ddexpand
...
end tell
This is slow because searching all stories to find those which match
the filter is slow (12-20 seconds in my case). What I'd really like to
do is return a list of all objects that match a filter, and then
further filter on that. Unfortunately this does not seem to be
feasable.
I'd like the moral equivalent of:
set mylist to the object reference of every word of every story whose
contents="MM" or contents="DD"
set every word of every item in mylist whose contents="MM" to mmexpand
set every word of every item in mylist whose contents="DD" to ddexpand
But this does not work, since filters cannot filter on lists.
What does work, but is painfully slow (2 minutes +) is:
set mylist to the object reference of every word of every story whose
contents="MM" or contents="DD"
repeat with i in mylist
set (every word of i whose (contents is equal to "MM")) to mmexpand
set (every word of i whose (contents is equal to "DD")) to ddexpand
end repeat
Any recommended solutions?
I also tried:
set every word of every story whose (contents="MM" or contents="DD") to
(my repl(its contents as string))
but it appeared that the repl() subroutine was only evaluated once,
rather than for each match of the filter.
Thanks for any assistance.
--jhawk
_______________________________________________
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.