2 Replies Latest reply on Aug 5, 2008 10:16 AM by GagnonEric

    [AS] Question on style and functions()

    Level 1
      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
        • 1. Re: [AS] Question on style and functions()
          sstanleyau Level 4
          On 30/7/08 2:42 AM, "SuperMacGuy" <member@adobeforums.com> wrote:<br /><br />> changeNewDocSize(myNewDoc, myGroupWidth, myGroupHeight)<br /><br />Inside a "tell app...", you need the word "my":<br /><br />  my changeNewDocSize(myNewDoc, myGroupWidth, myGroupHeight)<br /><br /><br />-- <br />Shane Stanley <sstanley@myriad-com.com.au>
          • 2. Re: [AS] Question on style and functions()
            GagnonEric
            I'm using alot the other equivalent syntax:

            me's changeNewDocSize

            and when using a script object:

            scriptObjectInstance's method()

            If this can be of interest to you, you can use the applemods framework to build and load your libraries (there is quite a few libraries in the framework also).

            I dont like very much the script server that loads and show up in the dock but it's still better than plain applescript.

            Go check this: http://applemods.sourceforge.net/modBrowser.html

            In fact, you are maybe better to start with:
            http://applemods.sourceforge.net/faq/index.html