Question
[AS] Question on style and functions()
Despite my screen name I'm not always Super with my scripting. I have a question about either why this doesn't work or how to properly format functions when it involves InDd.
I have a script that needs to open an existing ID document, and then it makes a new blank document, and adjusts the size of the new blank document to match the size of some items on the first document. It's inside a loop so I figure making a function could shorten things and/or make it more modular. I am going to need to have some handlers in case steps fail and I was thinking it may be easier to break out certain steps into functions to be able to handle errors, then close the file or move it to the "errors" folder etc.
TIA, Chris
Here is a shortened example of the script I am using:
tell application "Adobe InDesign CS3"
repeat with G from 1 to (count of myIDFilesList)
open file G of myIDFilesFolder
set myIDFile to document (item G of myIDFilesList)
-- ...do a bunch of things...
set myNewDoc to make new document
set myGroupWidth to ((item 4 of myGroupBounds) - (item 2 of myGroupBounds))
set myGroupHeight to ((item 3 of myGroupBounds) - (item 1 of myGroupBounds))
changeNewDocSize(myNewDoc, myGroupWidth, myGroupHeight)
-->here it errors and can't continue
-- ...do some more things...
end repeat
end tell
on changeNewDocSize(myNewDoc, myGroupWidth, myGroupHeight)
tell application "Adobe InDesign CS3"
tell myNewDoc
tell document preferences
set page width to myGroupWidth
set page height to myGroupHeight
end tell
end tell
end tell
end changeNewDocSize
I have a script that needs to open an existing ID document, and then it makes a new blank document, and adjusts the size of the new blank document to match the size of some items on the first document. It's inside a loop so I figure making a function could shorten things and/or make it more modular. I am going to need to have some handlers in case steps fail and I was thinking it may be easier to break out certain steps into functions to be able to handle errors, then close the file or move it to the "errors" folder etc.
TIA, Chris
Here is a shortened example of the script I am using:
tell application "Adobe InDesign CS3"
repeat with G from 1 to (count of myIDFilesList)
open file G of myIDFilesFolder
set myIDFile to document (item G of myIDFilesList)
-- ...do a bunch of things...
set myNewDoc to make new document
set myGroupWidth to ((item 4 of myGroupBounds) - (item 2 of myGroupBounds))
set myGroupHeight to ((item 3 of myGroupBounds) - (item 1 of myGroupBounds))
changeNewDocSize(myNewDoc, myGroupWidth, myGroupHeight)
-->here it errors and can't continue
-- ...do some more things...
end repeat
end tell
on changeNewDocSize(myNewDoc, myGroupWidth, myGroupHeight)
tell application "Adobe InDesign CS3"
tell myNewDoc
tell document preferences
set page width to myGroupWidth
set page height to myGroupHeight
end tell
end tell
end tell
end changeNewDocSize