Debugging a Procedure

How to:

Reference:

You can test and debug your procedure with the following.


Top of page

x
Syntax: How to Display Command Lines as They Execute
{-DEFAULT|-SET|EX procname} &ECHO = {ON|ALL|OFF}

where:

procname

Is the procedure to execute.

ON

Displays FOCUS commands that are expanded and stacked for execution.

ALL

Displays Dialogue Manager commands and FOCUS commands that are expanded and stacked for execution.

OFF

Suppresses the display of both stacked commands and Dialogue Manager commands. This value is the default.

Note: If you use -SET or -DEFAULT and place it in the procedure, display begins from that point in the procedure, and can be turned off and on again at any other point in the procedure.

If the procedure is encrypted, &ECHO automatically receives the value OFF, regardless of the value that is assigned explicitly.

By default, any procedure that does not explicitly set the &ECHO variable executes with the value OFF. You can change this default value for &ECHO with the SET DEFECHO command, as described in How to Establish a Default Value for the &ECHO Variable.


Top of page

x
Syntax: How to Establish a Default Value for the &ECHO Variable
SET DEFECHO = {OFF|ON|ALL}

where:

OFF

Establishes OFF as the default value for &ECHO. OFF is the default value.

ON

Establishes ON as the default value for &ECHO. ON displays WebFOCUS commands that are expanded and stacked for execution.

ALL

Establishes ALL as the default value for &ECHO. ALL displays Dialogue Manager commands and WebFOCUS commands that are expanded and stacked for execution.


Top of page

x
Syntax: How to Test Dialogue Manager Command Logic
{-DEFAULT|-SET|EX procname} &STACK = {ON|OFF}

where:

procname

Is the procedure to execute.

ON

Executes stacked commands normally. This value is the default.

OFF

Prevents the execution of stacked commands. In addition, system variables (for example, &RECORDS or &LINES) are not set. Dialogue Manager commands are executed so you can test the logic of the procedure.

Note: &STACK is usually used with &ECHO = ALL for debugging purposes. The terminal displays both the Dialogue Manager commands, as well as the FOCUS commands with the supplied values. You can view the logic of the procedure.



Example: Using the &RETCODE Variable to Test the Result of a Command

If you are using Simultaneous Usage (SU), you must know if the FOCUS Database Server is available before beginning a particular procedure. The following procedure tests whether SINK1 is available before launching PROC1.

? SU SINK1
-RUN
-IF &RETCODE EQ 16 GOTO BAD;
-INCLUDE PROC1
-BAD
-EXIT

Top of page

x
Reference: Testing the Status of a Query

The system variable &RETCODE returns a code after a query is executed. If the query results in a normal display, the value of &RETCODE is 0. If a display error occurs, or no display results (as can happen when the query finds no data), the value of &RETCODE is 8. (If the error occurs on a ? SU, the value of &RETCODE is 16.)

The value of &RETCODE is set following the execution of any of these queries:

 

NORMAL

NODISPLAY

ERROR

? HOLD

0

8

 

? SU* 

0

8

16

? JOIN

0

8

 

? COMBINE

0

8

 

? DEFINE

0

8

 

? USE

0

8

 

? LOAD

0

8

 

? FILEDEF

0

8

 

*The &RETCODE value of ? SU means: 0 indicates that the FOCUS Database Server (formerly called the sink machine) is up with one or more users; 8 indicates that the FOCUS Database Server is up with no users; 16 indicates that there is an error in communicating to the FOCUS Database Server.

You can test the status of any of these queries by checking the &RETCODE variable and providing branching instructions in your procedure.


Information Builders