Copy link to clipboard
Copied
I am running Acrobat Pro XI on a Windows 7 computer. I have placed the following code on a button so when the user clicks it the layer
"L730-A26" will turn off.
var colorLayer = "L730-A26";
var ocgSchematicArray = this.getOCGs(this.pageNum);
for (var i=0; i < ocgSchematicArray.length; i++){
if (ocgSchematicArray.name == colorLayer){
ocgSchematicArray.state = false;
}
}
I am getting this message:
I have run this exact code in the exact same way on another file without issue. I have deleted all the code and typed it all out (no copy and paste) to eliminate the possibility of odd characters from pasting.
Still no success. Can someone please tell me what I am doing wrong?
ExtendScript is not a general purpose JavaScript editor. Use either the internal editor or a tool like NotePad++
Copy link to clipboard
Copied
Your code looks OK (and when I copy&paste into a new document, it does not give me the syntax error). Do you have any other scripts in your document? What happens when you try to add the script line by line, or block by block? You can start out with just the first line, then add the second line, then create the for statement, but with an empty loop body. And so on.
Is there anything past the end of the script that you've posted? Can you share the file?
Copy link to clipboard
Copied
I don't have any code at the document level and nothing else besides what I posted on the button. I will try to paste it in line by line as you suggested. I can't share the file due to it's content being trademarked. I will post back after I try the line by line. Thank you for your help and quick response!
Copy link to clipboard
Copied
I get the same error on every line. So I deleted the document and started over. I created a brand new button and put the first line on it. Same error. Then same error for every line by itself. I really don't get what is going on. Again no copy and paste. Have rebooted the computer. Have recreated the file. Same error every time.
Copy link to clipboard
Copied
In what application are you writing the code?
Copy link to clipboard
Copied
I'm writing the code in Adobe Extendscript Toolkit CC. I'll try switching to the internal editor in Acrobat and see if that resolves the issue.
Thank you all for the replies!
Copy link to clipboard
Copied
ExtendScript is not a general purpose JavaScript editor. Use either the internal editor or a tool like NotePad++
Copy link to clipboard
Copied
I switched to NotePad++ and works perfectly! Thank you! I have never had an issue like this before. Grateful for the suggestions/help!
Copy link to clipboard
Copied
The illegal character is probably an invisible character inserted by your editing application.
Copy link to clipboard
Copied
What happens when you fix it?
Copy link to clipboard
Copied
All it does is takes me back in to allow me to edit the code