This content has been marked as final. Show 3 replies
The problem is in this line:
>var docObjectStyles = new Array(document.objectStyles.everyItem().name);
The statement document.objectStyles.everyItem().name creates an array, and you create an array out of that. Check what's in arrstring1 by adding after the line that begins with "var arrstring1 = '~' + doc..." this line:
You'd expect something like ~style1~style2~style3, but instead you get ~style1,style2,style3. Try your script with this line to create your docObjectStyles array.
>var docObjectStyles = document.objectStyles.everyItem().name;
Thanks very much. I see the problem now. I was making an array out of an array. I did not realize the line "document.objectStyles.everyItem().name" is an array itself.
I am very new at this, so I have yet another question. You said I should use "$.writeln (arrstring1);" to check the variable "arrstring1". I did so, but nothing happened. This is a method for debugging, right? But I did not see any result.
I am using ExtendScript Toolkit 2.
The console is an output/input window. It always displays the last result of a script after it has finished, but you can output intermediate results by using $.writeln(). Another way to check the value of a variable is to set a breakpoint somewhere, then type the variable's name in the console. For example, set a breakpoint at the line that begins with "var arrstring2 = '~' +" (click on the line number to set a breakpoint there; a red bullet appears to mark the breakpoint) and run the script. It stops at the breakpoint. Now click in the console, type arrstring1 and press Enter/Return. The current contents of the variale is printed in the console. You could do this for all variables that have been assigned a value so far (myDoc, myObjectStyles, etc.) Stepping through a script using F10 and/or F11 you can check intermediate results in the same way.
The console can also be used to type commands. For example, select a text frame in InDesign and type app.selection in the console: it prints [object TextFrame].