2 Replies Latest reply on Sep 19, 2013 7:39 AM by Marc Autret

    Clarification on script versions

    BEGINNER_X Level 3

      Hi All,


      I need a claification related to script versions.


      Question 1:


      If I create a script in CS4,


      use that script in CS5 also,  just by adding the coding in the top of the script


      app.scriptPreferences.version = 6.0;


      But if I create a script in CS5 and above.

      Is it possible to run the script in CS4 and below?



      Thanks in advance


        • 1. Re: Clarification on script versions
          BEGINNER_X Level 3

          Hi All,


          Could anyone provide solution or clarification on my request.


          Thanks in advance


          • 2. Re: Clarification on script versions
            Marc Autret Level 5

            Hi Beginner_X,


            There are a huge number of issues in that topic and I'm not even sure I could give a proper picture of the basics. Anyway, here are a few key rules you should keep in mind:


            1) Cross-DOM Rule: As long as a script only invokes DOM methods and features that are common to all InDesign versions under consideration—say app.selection or myDocument.pageItems—the code remains univoque and you don't need to specify app.scriptPreferences.version to get it properly working whatever the version from which you run it. The script is cross-version.


            2) Time Arrow Rule: CS5 may have knowledge about CS4 specific features, but CS4 cannot have knowledge about CS5 specific features! Therefore, no matter how your code is 'interpreted' or 'translated' from a DOM version to another, there is no way to make InDesign CS4 understand and manage a topLeftCornerOption. The CS4 scripting DOM only knows the uniform cornerOption property:


            // topLeftCornerOption is definitely not available in CS4
            app.scriptPreferences.version = 7.0; // has no effet, seen from CS4!
            alert( myRectangle.topLeftCornerOption );  // CS4: Game over! -- CS5: OK


            3) Retro-Versioning Rule: To some respect, you can tell to CS5 that your code (or part of your code) is CS4 DOM-based, using the app.scriptPreferences.version = 6.0 directive. This allows to switch to a previous scripting DOM, provided that the underlying objects (in the CS5 document) can be mapped to a CS4 feature:


            // topLeftCornerOption is a CS5 specific feature
            // cornerOption is a CS4 feature (not available in CS5 but 'mappable')
            alert( myRectangle.topLeftCornerOption ); // CS5: OK -- CS4: Game over!
            app.scriptPreferences.version = 6.0; // Go back to CS4
            alert( myRectangle.cornerOption ); // OK (mapped from topLeftCornerOption, I think)
            app.scriptPreferences.version = 7.0; // Go back to CS5
            alert( myRectangle.topLeftCornerOption ); // OK


            A crucial aspect of the Retro-Versioning Rule is that it not only makes previous DOM tokens available, it also may change the meaning, or the behavior, of an existing method/property. For example:


            alert( typeof SpecialCharacters.BULLET_CHARACTER ); // CS4: Number -- CS6: Object
            app.scriptPreferences.version = 6.0; // Go back to CS4
            alert( typeof SpecialCharacters.BULLET_CHARACTER ); // CS4: Number -- CS6: Number



            That said, there are many other tricky problems (and bugs!) that make cross-versioning a pure nightmare for complex projects—in particular when ScriptUI is involved, but this is another story…


            Hope that helps,



            1 person found this helpful