Debugging

When you are writing complex formulas, it is likely that they will not immediately function as intended. Although the compiler tries to catch most of the common mistakes and reports them as errors or warnings, some mistakes will go unnoticed until you try the formula.

The process of trying a formula and correcting it until it works is called debugging, because you are essentially removing bugs (programming mistakes). To debug a formula, you use run-time messages.

Run-time messages can be generated by a formula while it is executed. They appear in the Compiler Messages tool window, where you can examine them.

To enable run-time messages, define the DEBUG symbol. Run-time messages are caused by an array index that is out of bounds, an assignment of incompatible arrays, or by the print function. Here is an example:

  int a[4]  int i = 5  a[i] = 4              ; out of bounds, no run-time message  print("Hello?")       ; ignored  $define DEBUG  a[i] = 3              ; out of bounds, causes run-time message  print("Hello, world") ; causes run-time message    

Use the print function to examine the values of variables while the formula is executed, so you can understand why it is not working properly.

Ultra Fractal reload Debugging  

Run-time messages are printed to the Compiler Messages tool window. To make sure the Compiler Messages tool window is attached to the formula you want to debug, click the Reload button for the formula in one of the tabs of the Layer Properties tool window.

By not defining the DEBUG symbol, run-time messages are not generated. When you are publishing a formula, you should make sure the DEBUG symbol is not defined, since the users of your formula will probably not appreciate the run-time messages.

Next: Optimizations

See Also
print function
Compiler directives
Memory management

Debugging