1 Reply Latest reply on Jun 28, 2013 8:31 AM by CarlosCanto

    How to debug an Illustrator script palette button / object?

    alanomaly Level 1

      I've got a script that creates a palette that does some calculations when a button is pressed - but something in the script is failing silently. (this question is about how to debug things like this, not what the problem is in my specific script)

       

      I've read the debugging tips in the Javascript tools guide, and based on that, re-opened the script in the Extendscript Toolkit instead of my usual text editor, chosen Illustrator, and hit the green 'Go' button. But, either I've missed something fundamental, or this isn't designed for palettes - the script runs in Illustrator, successfully pops up the palette, considers the job done, pats itself on the back, and closes the palette before I can begin debugging the button.

       

      I'm looking for something where I can test the palette doing regular Illustrator work and see debug messages, set breakpoints, etc. I've tried the old-school approach of just filling the code with 'alert("blah")'s but it doesn't work - my code reaches an " if(app.activeDocument.selection.length){ alert(1);} else {alert(2);} and doesn't alert either of them, or give any error message.

       

      What's the standard way to debug something like this? If I was working in a browser, I'd just plonk in a "console.log( app.activeDocument.selection )" and browse the object structure to see what's going on, is there any Illustrator equivalent?

       

       

      (p.s. unrelated, is there any way to mark inline code on this forum?)

        • 1. Re: How to debug an Illustrator script palette button / object?
          CarlosCanto Adobe Community Professional & MVP

          to post formatted code, you first have to click on the "Use advanced editor" in your Post Widget, then type or paste your code, select it and click on the "chevron" icon called "insert", that's a menu that will show the options "Syntax Highlighting", then click on "Java"

           

          to debug your code, there's a debug Menu in the ESTK, it is all explained in the one of the Documents, I think it is in the Intro to Scripting, not sure

           

           

          "console.log( app.activeDocument.selection )" and browse the object structure to see what's going on, is there any Illustrator equivalent?

           

           

          use

          $.writeln(app.activeDocument.name)