Debugging formulas

The formula language does not provide a formal debugging mechanism. You can use @Prompt to stop at certain points and to examine variables. This example uses @Prompt to set a checkpoint and then to examine a variable. After you establish that your code is running correctly, remove the debug statements.

@Prompt([OK]; "Checkpoint"; "About to calculate LastName");
LastName := @RightBack(@Left(@UserName; "/"); " ");
@Prompt([OK]; "Value of LastName"; LastName)

In some cases, such as agents that do not run on the current document and selection formulas, @Prompt does not work. You do not receive a caution when you write or run the formula -- the statement simply does not run. To work around this problem, you can write the formula in an action, toolbar button, or some other object in which @Prompt works. After testing the formula there, remove the debug statements and copy and paste the formula into the desired object.

Alternatively, you can design debug fields into the form for the documents your formula processes. Your formula loads the debug fields during testing and you open the documents processed to examine the fields. After testing, remove the debug fields from the form as well as the debug statements from the formula.

FIELD DebugLastName := lastName