Debugging Calculations and Scripts

Designer includes various features and strategies for debugging calculations and scripts, depending on the scripting language you choose.

For JavaScript language script debugging, you can use the alert or the messageBox methods to provide debugging feedback. One disadvantage of this method is that you must close many message boxes. Another problem is that displaying a message box can cause differences in the form’s behavior, especially if you are trying to debug a script that is setting focus to an object on your form. It is best to use console.println to output text to the JavaScript Console from Acrobat to debug a form.

Designer Report palette warning and validation messages

The Report palette provides warning and validation messages to help you debug a form as you design it. The Warning tab lets you view errors or messages that Designer generated as you design a form. The Log tab lets you view the following errors and messages:

  • Validation messages

  • JavaScript or FormCalc scripting execution errors

  • Design-time form rendering errors that are generated when you import or save a form or preview a form from the Preview PDF tab.

For more information about using the Report palette, see Using the workspace to debug calculations and scripts.

Providing debugging feedback using the messageBox method

The XML Form Object Model messageBox method lets you output information from an interactive form into a dialog box at run time. You can take advantage of the XML Form Object Model messageBox method to display messages or field values at runtime. When initiated, the messageBox method displays a string value in a new client application dialog box. The string value can be a text message that you create for debugging purposes or the string value of fields or expressions.

For example, consider a scenario with a simple form design that contains a single numeric field (NumericField1) and a button (Button1). In this case, the following FormCalc calculation and JavaScript script each output a message displaying some text and the value currently displayed in the numeric field. By adding either the calculation or the script to the click event of the button object, you can interactively display the value of the numeric field in a new dialog box by clicking the button.

FormCalc

    xfa.host.messageBox(Concat("The value of NumericField1 is: ", 
        NumericField1), "Debugging", 3)

JavaScript

    xfa.host.messageBox("The value of NumericField1 is: " + 
        NumericField1.rawValue, "Debugging", 3);
Important: The messageBox method returns an integer value representing the button that the form filler selects in the message box dialog. If you attach the messageBox method to the calculate event of a field object, and the messagebox method is the last line of the script, the field displays the return value of the messageBox method at runtime.

For more informatin about using the messageBox, see messageBox

Output information into a text field

You can output information, such as field values or messages, into a text field on your form design. For example, you can append new messages or values to the value of a text field to create a log for future reference..