Using the #DEBUG Command

When debugging a program, you should:

  • Display data or show when a procedure or query runs by using temporary SHOW or DISPLAY commands in key places in the program.

  • Isolate problem areas by temporarily skipping the parts of the program that work correctly.

  • Temporarily cause additional behavior in questionable areas of the program.

    For example, display or modify variables that you suspect are causing a problem.

SQR provides the #DEBUG command to help you make temporary changes to the code. Use the #DEBUG command to conditionally process portions of the program.

Precede the command with #DEBUG, as shown in the following example:

#debug display $s

When the #DEBUG precedes a command, that command is processed only if the -DEBUG flag is specified in the SQR command line. In this example, the value of $s appears only when you run the program with -DEBUG.

You can obtain multiple debug commands by using up to 10 letters or digits to differentiate between them. Indicate which command is to be debugged on the -DEBUG flag, as shown in the following example:

sqr myreport username/password -DEBUGabc

In this example, commands that are preceded by #DEBUG, #DEBUGa, #DEBUGb, or #DEBUGc are compiled when the program is run. Commands that are preceded with #DEBUGd are not compiled because d was not specified in the -DEBUG command-line flag.