« Who Am I? | Main | What's new in 7.1? »

Debugging Scripts

Please note: This blog has been migrated to a new server. To ensure you get the most recent posts, updates and comments, please update your bookmarks to Stefan Cameron on Forms.

Here’s a simple tip that could make a huge difference in your ability to debug your scripts in Designer:

If you use the JavaScript language for a script, you can use the following function to output information to the Acrobat Console:

console.println("string");

Anyone who has attempted to debug their script(s) in Acrobat knows that it’s a painful thing to do. Unfortunately, many only know about

app.alert("string");

or

xfa.host.messageBox("string");

which gets the job done but not without some headaches and, in certain cases, RSI in your index finger! The other problem is that showing a message box can cause differences in the form’s behaviour especially if you’re trying to debug a script which is setting focus to an object on your form. The fact that a dialog is displayed can really mess things up.

By using console.println, you can output text to the Acrobat Console (when in Acrobat — even Preview in Designer — just press Ctrl + J to display it) so that you don’t change the behaviour of your scripts.

The ability to debug scripts is something we know needs serious attention in Designer and trust me, we’ve talked about it and we have plans to address these issues but I can’t speak about anything definite at this time.


Updated: November 1, 2006

Comments

Another technique I use is putting a text field on the form and using it as a debug output field - setting it's text in the click event with the results of the code that's handling the click, for example.

It's right in between app.alert and console.println - no RSI from closing the alerts, and no having to bring up the JavaScript console. But you do have to remember to remove this field (and the code that sets it) before you're done with your form.

Hi Formbuilder

Thanks for the tip with
console.println(...);

YES the scripting and debugging features in designer are limited and need more attention if Adobe wants the platform to be a serious choice for big solutions/companies.

When you are used to code completion etc. from Visual studio, eclipse etc. you feel like you were set 5+ years back in time!

/Thomas
Jyske Bank - Denmark

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)