You can display the value of variables by using:
The scope of the variables used in the EVAL command is defined by using the QUAL command. However, you do not need to specifically define the scope of the variables contained in a CL module because they are all of global scope.
To display a variable using F11 (Display variable), place your cursor on the variable that you want to display and press F11. The current value of the variable is shown on the message line at the bottom of the Display Module Source display.
Figure 10-8. Displaying a Variable using F11 (Display variable). Using the EVAL Debug Command
+--------------------------------------------------------------------------------+
| Display Module Source |
| |
| Program: DSPWKDAY Library: MYLIB Module: DSPWKDAY |
| 4 DCL VAR(&MSGTEXT) TYPE(*CHAR) LEN(20) |
| 5 CALL PGM(WEEKDAY2) PARM(&DAYOFWK) |
| 6 IF COND(&DAYOFWK *EQ 1) THEN(CHGVAR + |
| 7 VAR(&WEEKDAY) VALUE('Sunday')) |
| 8 ELSE CMD(IF COND(&DAYOFWK *EQ 2) THEN(CHGVAR + |
| 9 VAR(&WEEKDAY) VALUE('Monday'))) |
| 10 ELSE CMD(IF COND(&DAYOFWK *EQ 3) THEN(CHGVAR + |
| 11 VAR(&WEEKDAY) VALUE('Tuesday'))) |
| 12 ELSE CMD(IF COND(&DAYOFWK *EQ 4) THEN(CHGVAR + |
| 13 VAR(&WEEKDAY) VALUE('Wednesday'))) |
| 14 ELSE CMD(IF COND(&DAYOFWK *EQ 5) THEN(CHGVAR + |
| 15 VAR(&WEEKDAY) VALUE('Thursday'))) |
| 16 ELSE CMD(IF COND(&DAYOFWK *EQ 6) THEN(CHGVAR + |
| 17 VAR(&WEEKDAY) VALUE('Friday'))) |
| 18 ELSE CMD(IF COND(&DAYOFWK *EQ 7) THEN(CHGVAR + |
| More... |
| Debug . . . |
| |
| |
| F3=End program F6=Add/Clear breakpoint F10=Step F11=Display variable |
| F12=Resume F17=Watch Variable F18=Work with watch F24=More keys |
| &DAYOFWK = 3. |
+--------------------------------------------------------------------------------+
You can also use the EVAL debug command to determine the value of a variable. To display the value of a variable using the EVAL debug command, type:
EVAL variable-name
on the debug command line. Variable-name is the name of the variable that you want to display. The value of the variable is shown on the message line if the EVAL debug command is entered from the Display Module Source display and the value can be shown on a single line. If the value cannot be shown on a single line, it is shown on the Evaluate Expression display.
For example, to display the value of the variable &DAYOFWK; on line 7 of the module object shown in Figure 10-8, type:
EVAL &DAYOFWK
The message line of the Display Module Source display shows &DAYOFWK = 3. as in Figure 10-8.
CL declarations: DCL VAR(&LGL1) TYPE(*LGL) VALUE('1') Debug command: EVAL &LGL1 Result: &LGL1 = '1'
CL declarations: DCL VAR(&CHAR1) TYPE(*CHAR) LEN(10) VALUE('EXAMPLE') Debug command: EVAL &CHAR1 Result: &CHAR1 = 'EXAMPLE ' Debug command: EVAL %SUBSTR(&CHAR1 5 3) Result: %SUBSTR(&CHAR1 5 3) = 'PLE' Debug command: EVAL %SUBSTR(&CHAR1 7 4) Result: %SUBSTR(&CHAR1 7 4) = 'E '
The %SUBSTR built-in function allows you to substring a character string variable. The first argument must be a string identifier, the second argument is the starting position, and the third argument is the number of single byte or double byte characters. Arguments are delimited by one or more spaces.
CL declarations: DCL VAR(&DEC1) TYPE(*DEC) LEN(4 1) VALUE(73.1) CL declarations: DCL VAR(&DEC2) TYPE(*DEC) LEN(3 1) VALUE(12.5) Debug command: EVAL &DEC1 Result: &DEC1 = 073.1 Debug command: EVAL &DEC2 Result: &DEC2 = 12.5
You can use the EVAL debug command to display the value of variables in hexadecimal format. To display a variable in hexadecimal format, on the debug command line, type:
EVAL variable-name: x number-of-bytesVariable-name is the name of the variable that you want to display in hexadecimal format. 'x' specifies that the variable is to be displayed in hexadecimal format and number-of-bytes indicates the number of bytes displayed. If no length is specified after the 'x', the size of the variable is used as the length. A minimum of 16 bytes is always displayed. If the length of the variable is less than 16 bytes, then the remaining space is filled with zeroes until the 16 byte boundary is reached.
CL declaration: DCL VAR(&CHAR1) TYPE(*CHAR) LEN(10) VALUE('ABC') DCL VAR(&CHAR2) TYPE(*CHAR) LEN(10) VALUE('DEF') Debug command: EVAL &CHAR1:X 32 Result: 00000 C1C2C340 40404040 4040C4C5 C6404040 ABC DEF 00010 40404040 00000000 00000000 00000000 ............
(C) Copyright IBM Corporation 1992, 2005. All Rights Reserved.