Quantcast
Channel: Adobe Community : Popular Discussions - InDesign Scripting
Viewing all articles
Browse latest Browse all 15932

Deeply nested object literal woes

$
0
0

I'm trying to set up a deeply nested object that I can access throughout my script. It usese a mix of arrays, associative arrays, functions and more. I'm declaring at the top of the script in the global space. Here's what it looks like, more or less, with all the syntax:

 

    var myNS = {

          styles: {

               HEAD1 : "Headline1",

               HEAD2: "Headline2",

               ...

          },

         

          authors: {

               jd: ["John Doe", "His Title", "hisemailaddress.com"],

               wb: ["Willy Bob", "Some Other Title", "wbemail@.com],

               ...

          },

 

          types: {

             type1: {

                elems: {

                     "String Field1": { text: "Some kind of text", },

                     "SF 2": { text: "replacement text", },

                     "Another string field" : { text: "More text", },

                 },

             },

             type2: { ...

         

          }, //end types

         

          func1: function( aParam ) {

               ///some code

          },

 

          //and so on until the variable declaration ends with a closing bracket and a semicolon

   };

 

I'm accessing this global beast of an object elsewhere in the code -- in constructors for other objects, object prototypes, private functions in constructors, etc. For example:

     myStory.paragraphs[0].appliedParagraphStyle = myNS.styles.HEAD1;

 

Unfortunately, when I run the script, I get error code 21 on the "var myNS = { " line, saying undefined is not an object.

 

I should have avoid the nested structure in the first place, but does anyone know if InDesign CS3 doesn't like nested object literals or if they can see anything in my syntax that might be throwing it for a loop? I've been staring at the dang thing for hours now... probably could have rewritten the structure in that time. Stubborn me.


Viewing all articles
Browse latest Browse all 15932

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>