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: Shane Stanley <email@hidden>
- Date: Sat, 03 Mar 2012 21:57:31 +1100
On 03/03/2012, at 10:51 AM, Rick Gordon wrote:
> 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 vMyPath to path to me
> tell application "Finder" to set vParentFolderPath to folder of vMyPath as string
It may seem a nit, but why risk slowing things down by asking the Finder for something you can more quickly and easily get yourself?
set vMyPath to path to me as text
set saveTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to {":"}
set vParentFolderPath to (text 1 thru text item -3 of vMyPath) & ":"
set AppleScript's text item delimiters to saveTID
> set vScript1 to (vParentFolderPath & "Script-01.scpt") as alias
> set vScript2 to (vParentFolderPath & "Script-02.scpt") as alias
> set vScript3 to (vParentFolderPath & "Script-03.scpt") as alias
>
> tell application "Adobe InDesign CS5.5"
> set vApp to a reference to it
> tell active book
> set vItemCount to count items of book contents
> repeat with i from 1 to vItemCount
> tell item i of (book contents as list)
> set vBookItem to object reference
> tell vApp to set vCurrentDoc to open full name of vBookItem without showing window
> tell vCurrentDoc
> run script vScript1
> run script vScript2
> run script vScript3
"run script" is from Standard Additions. With some obvious exceptions -- display dialog and its UI ilk -- you should not call scripting additions commands within application tell blocks. Again, it's going to make little difference in time, but it's the sort of thing that might well break one day. The 10.6 AppleScript release notes say specifically that you shouldn't do it.
I'm not sure what you hope to achieve by trying to target run script at a document, but run script doesn't work like that. If you want to pass parameters via run script (and I don't think you do here), use the "with parameters" parameter.
--
Shane Stanley <email@hidden>
'AppleScriptObjC Explored' <www.macosxautomation.com/applescript/apps/>
_______________________________________________
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