Re: Overhead in Using Run Script in a Loop ???
Re: Overhead in Using Run Script in a Loop ???
- Subject: Re: Overhead in Using Run Script in a Loop ???
- From: Axel Luttgens <email@hidden>
- Date: Sat, 03 Mar 2012 16:06:01 +0100
Le 3 mars 2012 à 00:51, Rick Gordon a écrit :
> I'm setting up a script to run successively on the contents of a InDesign book, and rather than building all the functionality into a single file, I'd prefer to use run script to run other scripts that are configured to operate on one document (many of which are already written) like this:
>
> [...]
> set vScript1 to (vParentFolderPath & "Script-01.scpt") as alias
> [...]
> tell application "Adobe InDesign CS5.5"
> [...]
> repeat with i from 1 to vItemCount
> [...]
> run script vScript1
> [...]
> end repeat
> [...]
> end tell
>
> On a large number of files, is there an overhead problem with this approach?
Hello Rick,
Shane (and presumably Yvan, but I didn't see his message) have already provided you with some ideas.
An additional one: each invocation of "run script" in the above potentially results in reading the script's file from disk and creating a separate execution context. So, yes, there should be some overhead...
Instead of "run script", you could consider "load script" and make use of the returned script object; let's say "Script-01.scpt" is on the Desktop and contains:
display dialog "From Script-01.scpt!"
on CustDialog(Str)
display dialog "From Script-01.scpt: " & Str & "!"
end CustDialog
You could then have in your main script, for example:
set Script01 to load script alias ((path to desktop as text) & "Script-01.scpt")
tell Script01 to run
Script01's CustDialog("Hey")
Applied to your example:
[...]
set vScript1 to load script alias (vParentFolderPath & "Script-01.scpt")
[...]
tell application "Adobe InDesign CS5.5"
[...]
repeat with i from 1 to vItemCount
[...]
tell vScript1 to run
[...]
end repeat
[...]
end tell
HTH,
Axel
_______________________________________________
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