Skip navigation
Currently Being Moderated

InDesign modifieds/inflates compiled AppleScript

May 2, 2012 5:46 AM

Tags: #script #indesign_cs5.5 #applescript #compile

Running into a problem with InDesign changing my compiled AS files. It appears that certain values are being cached (by InDesign) within the compiled version after being run from the Scripts Panel and when those scripts are then shared with other users, they contain references to paths and hard drives on my machine. However, if I share the compiled versions without running them first within the Scripts Panel, they won't have the cached values.

 

So my question, why is InDesign changing the compiled versions of my AS?

How to do I prevent InDesign from changing the the compiled scripts?

Could it have something with the undo modes in the do script even though my scripts aren't using do script?

 

Example: active_script.scpt

tell application "Adobe InDesign CS5.5"

  set myScript to active script

  display dialog ("The current script is: " & myScript)

  tell application "Finder"

  set myFile to file myScript

  set myParentFolder to container of myFile

  end tell

  display dialog ("The folder containing the active script is: " & myParentFolder)

end tell

 

Here is the process to reproduce:

 

  1. Create an compiled AS file using Script Editor. 
  2. Look at the size of the file. (2,971 bytes for active_script.scpt)
  3. Put it in the Scripts Panel folder.
  4. Run it from the Scripts Panel.
  5. Look at the size of the file again. (5,231 bytes)

 

In fact, if you do #2-5 over and over again, you'll see the file size increasingly grow in size. For instance:

 

Script Editor compile: 2,971 bytes

InDesign run: 4,049 bytes

Script Editor compile and save: 3,168 bytes (Gives warning: "This document’s file has been changed by another application since you opened or saved it. The changes made by the other application will be lost if you save. Save anyway?")

InDesign run: 4,246 bytes

Script Editor compile and save: 3,365 bytes (Gives warning: "This document’s file has been changed by another application since you opened or saved it. The changes made by the other application will be lost if you save. Save anyway?")

InDesign run: 4,443 bytes

etc. etc.

 

My environment: OSX 10.6, InDesign CS5.5, AppleScript 2.1.2

 
Replies
  • Currently Being Moderated
    May 7, 2012 8:40 AM   in reply to Shawn Pyle

    I would usually expect to see this kind of behaviour with a "property : value" construct, where properties would usually be stored back into the script.

    After running your script a few times, it seemed to me the file size stopped increasing after a certain point.

    I can't really comment on why exactly this is happening, I've not experienced such a thing before. I never had to use active script or display info about it.

    Could  you give us some background on what exactly you are using it for? It seems unusual to have to display the current script name or location. Maybe there is a better way.

    Have you tried simply setting the var to nothing at the beginning of the script? It's not necessarily elegant but it might do the job.

     

    OSX 10.6.8, IDCS5, Script Debugger 4.5x

     
    |
    Mark as:
  • Currently Being Moderated
    May 7, 2012 6:24 PM   in reply to Shawn Pyle

    That's normal behavior. When an app runs a script, it then saves it back to disk. That version contains the contents of any modified properties, as SuperMacGuy says, but it also includes the value of any *top level* variables. So you need move any variables you don't want stored out of the top level of the script -- essentially put it all in a handler.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points