The simplest way to display the value of a variable is to use F11 (Display variable) on the Display Module Source display. To display a variable using F11 (Display variable), place your cursor on the variable that you want to display and press F11 (Display variable). The current value of the variable is shown on the message line at the bottom of the Display Module Source display. For example, if you want to see the value of variable COUNTER on line 221 of the module object shown in Figure 44, place you cursor on top of the variable and press F11 (Display variable). The current value of the variable COUNTER is shown on the message line.
Figure 44. Displaying a Variable using F11 (Display variable)
+--------------------------------------------------------------------------------+ | Display Module Source | | Program: TEST Library: TESTLIB Module: SAMPMDF | | 213 | | 214 PROCEDURE-SECTION SECTION. | | 215 FILL-TERMINAL-LIST. | | 216 READ TERMINAL-FILE RECORD INTO LIST-OF-TERMINALS(COUNTER) | | 217 AT END | | 218 SET END-OF-TERMINAL-LIST TO TRUE | | 219 SUBTRACT 1 FROM COUNTER | | 220 MOVE COUNTER TO NO-OF-TERMINALS. | | 221 ADD 1 TO COUNTER. | | 222 | | 223 ACQUIRE-AND-INVITE-TERMINALS. | | 224 ACQUIRE LIST-OF-TERMINALS(COUNTER) FOR MULTIPLE FILE. | | 225 WRITE MULTIPLE-REC | | 226 FORMAT IS "SIGNON" | | 227 TERMINAL IS LIST-OF-TERMINALS(COUNTER). | | 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 | | COUNTER = 89. | +--------------------------------------------------------------------------------+
In cases where you are evaluating records, group items, or arrays, the message returned when you press F11 (Display variable) may span several lines. Messages that span several lines are shown on the Evaluate Expression display to show the entire text of the message. Once you have finished viewing the message on the Evaluate Expression display, press Enter to return to the Display Module Source display.
You can also use the EVAL debug command to determine the value of a variable. First, you use the QUAL debug command to identify the line number of the variable that you want to show. Scoping rules for the variable are applied from this line.
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. Otherwise, the value of the variable is shown on the Evaluate Expression display.
For example, to display the value of the variable COUNTER on line 221 of the module object shown in Figure 44, type:
EVAL COUNTER
The message line of the Display Module Source display shows COUNTER = 89 as in Figure 45.
Figure 45. Displaying a Variable using the EVAL debug command
+--------------------------------------------------------------------------------+ | Display Module Source | | Program: TEST Library: TESTLIB Module: SAMPMDF | | 213 | | 214 PROCEDURE-SECTION SECTION. | | 215 FILL-TERMINAL-LIST. | | 216 READ TERMINAL-FILE RECORD INTO LIST-OF-TERMINALS(COUNTER) | | 217 AT END | | 218 SET END-OF-TERMINAL-LIST TO TRUE | | 219 SUBTRACT 1 FROM COUNTER | | 220 MOVE COUNTER TO NO-OF-TERMINALS. | | 221 ADD 1 TO COUNTER. | | 222 | | 223 ACQUIRE-AND-INVITE-TERMINALS. | | 224 ACQUIRE LIST-OF-TERMINALS(COUNTER) FOR MULTIPLE FILE. | | 225 WRITE MULTIPLE-REC | | 226 FORMAT IS "SIGNON" | | 227 TERMINAL IS LIST-OF-TERMINALS(COUNTER). | | 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 | | COUNTER = 89. | +--------------------------------------------------------------------------------+
You can use the EVAL debug command to display the value of variables in hexadecimal format. To display a variable in hexadecimal format, type:
EVAL variable-name: x 32
on the debug command line. variable-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 '32' indicates that a dump of 32 bytes after the start of the variable is to be displayed. The hexadecimal value of the variable is shown on the Evaluate Expression display as in Figure 46. 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.
Figure 46. Displaying the Hexadecimal Value of a Variable using the EVAL debug command
+--------------------------------------------------------------------------------+ | Evaluate Expression | | Previous debug expressions | | > BREAK 221 | | > EVAL COUNTER | | COUNTER = 89. | | > EVAL B : X 32 | | 00000 F8F90000 00000000 00000000 00000000 - 89.............. | | 00010 00000000 00000000 00000000 00000000 - ................ | | | | | | | | | | | | | | Bottom | | Debug . . . ________________________________________________________________| |_______________________________________________________________________________ | | F3=Exit F9=Retrieve F12=Cancel F19=Left F20=Right F21=Command entry | | | +--------------------------------------------------------------------------------+
The ILE source debugger does not support the reference modification syntax of ILE COBOL. Instead, you can use the %SUBSTR operator with the EVAL command to display a substring of a character string variable. The %SUBSTR operator obtains the substring of a character string variable from a starting element position for some number of elements.
The syntax for the %SUBSTR operator is as follows:
%SUBSTR(identifier start-element number-of-elements)
where identifier must be a character string variable, and start-element and number-of-elements must be non-zero, positive integer literals. identifier can be a qualified, subscripted, or indexed variable. start-element + number-of-elements - 1 cannot be greater than the total number of elements in identifier.
For example, you can obtain the first 10 elements of a 20-element character string by using %SUBSTR(char20 1 10). You can obtain the last 5 elements of a 8-element character string by using %SUBSTR(char8 4 5). In the case of a DBCS or DBCS-edited item, element refers to a DBCS character (in other words, a two-byte character).
You can use the %SUBSTR operator to assign a substring of a character string variable to another variable or substring of a variable. Data is copied from the source variable to the target variable from left to right. When the source or target variables or both are substrings, then the operand is the substring portion of the character string variable, not the entire character string variable. When the source and target variable are of different sizes, then the following truncation and padding rules apply:
Figure 47 shows some example of how the %SUBSTR operator can be used.
Figure 47. Displaying a Substring of a Character String Variable using the %SUBSTR operator
+--------------------------------------------------------------------------------+ | Evaluate Expression | | Previous Debug expressions | | > EVAL CHAR10 | | CHAR10 = '10CHARLONG' | | > EVAL CHARA | | CHARA = 'A' | | > EVAL CHARA = %SUBSTR(CHAR10 3 5) | | CHARA = 'C' | | > EVAL %SUBSTR(CHAR10 1 2) = 'A' | | CHAR10 = 'A CHARLONG' | | > EVAL %SUBSTR(CHAR10 1 2) = 'XYZ' | | CHAR10 = 'XYCHARLONG' | | > EVAL %SUBSTR(CHAR10 7 4) = 'ABCD' | | CHAR10 = 'XYCHARABCD' | | > EVAL %SUBSTR(CHAR10 1 2) = %SUBSTR(CHAR10 7 4) | | CHAR10 = 'ABCHARABCD' | | Bottom | | Debug . . . _________________________________________________________________| | _______________________________________________________________________________| | F3=Exit F9=Retrieve F12=Cancel F19=Left F20=Right F21=Command entry | +--------------------------------------------------------------------------------+
You can use the ILE source debugger %ADDR operator with the EVAL command to display the address of a level-01 or level-77 data item. To display a level-01 or level-77 variable's address, type:
EVAL %ADDR(variable-name)
There is no dereference operator in ILE COBOL, but you still can display the area where the pointer data item points to as hexadecimal values or character values. To display the target area of a pointer data item as hexadecimal values, type:
EVAL pointer-name: x size
To display the target area of a pointer data item as character values, type:
EVAL pointer-name: c size
(C) Copyright IBM Corporation 1992, 2005. All Rights Reserved.