#DEBUG

Function

Causes the current command to process during a debugging session.

Syntax

#DEBUG[x...]sqr_command

Arguments

x

Any letter or digit.

Description

A -DEBUG[xx] flag in the Production Reporting command line allows conditional compilation of Production Reporting commands. When this flag is used, any command (including other compiler directives) preceded by the word #DEBUG is processed; otherwise, the command is 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 be suffixed by up to 36 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 turn whole sections of code on or off for debugging.

Examples

The following Production Reporting command line contains the -DEBUG flag with no suffixes:

sqr  myprog  sammy/baker  -debug

The following SHOW command in the program executes 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 example, the command line contains the -DEBUG flag with the suffixes a, b, and c:

sqr  myprog  sammy/baker  -debugabc

In the following program segment, the first three #DEBUG commands are compiled, but the fourth, beginning “#debuge”, is not since 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 example shows the use of an #IF with a #DEBUG:

#debuga  #if {platform}='unix'
#debuga  show 'Platform is UNIX'
#debuga  #endif

See Also

#IF, #IFDEF, and #IFNDEF