#DEBUG
Syntax
#DEBUG[x...]SQR_Command
Description
Causes the current command to be processed during a debugging session.
A -DEBUG[xx] flag in the SQR command line enables conditional compilation of SQR commands. When this flag is used, any command (including other compiler directives) preceded by the word #DEBUG is processed; other commands are ignored.
This is useful for placing DISPLAY, SHOW, PRINT or other commands in your program for testing and for deactivating them when the report goes into production.
The -DEBUG flag can contain a suffix of up to 10 letters or digits. These characters are used to match any letters or digits appended to the #DEBUG preprocess command inside the program. #DEBUG commands with one or more matching suffix characters are processed; other commands are ignored. Commands without any suffix always match.
In addition, for each -DEBUGxx letter, a substitution variable is defined. For example, if the flag -DEBUGab is used on the command line, three substitution variables are defined: debug, debuga, and debugb. These variables can be referenced in #IFDEF commands to enable or disable whole sections of code for debugging.
Parameters
| Parameter | Description |
|---|---|
|
x |
Represents any letter or digit. |
Example
The following SQR command line contains the -DEBUG flag with no suffixes:
sqr myprog sammy/baker -debug
The following SHOW command in the program is carried out if invoked with the previous command line because the -DEBUG flag was used:
#debug show 'The total is ' #grand-tot 999,999,999
In the following code example, the command line contains the -DEBUG flag with the suffixes a, b, and c:
sqr myprog sammy/baker -debugabc
In the following code example, the first three #DEBUG commands are compiled, but the fourth, beginning #debuge, is not because its suffix does not match any of the suffixes on the -DEBUG flag:
#debuga show 'Now selecting rows...'
#debug show 'Finished query.'
#debugb show 'Inserting new row.'
#debuge show 'Deleting row.'
The following code example shows the use of an #IF with a #DEBUG:
#debuga #if {platform}='unix'
#debuga show 'Platform is UNIX'
#debuga #endif
See Commands The #IF, #IFDEF, #IFNDEF