Displaying Data and Expressions

You can display the contents of fields, data structures, and arrays, and you can evaluate expressions. There are two ways to display or evaluate:

For simple qualified names, of the form DS.SUBF, you can use either of these commands to display or change the variable:

EVAL SUBF OF DS
EVAL DS.SUBF

For complex qualified names, use the dot-qualification form of the name:

EVAL FAMILY.CHILD(2).PETS.PET(3).NAME

The scope of the fields used in the EVAL command can be defined by using the QUAL command in languages such as ILE C. However, this command does not currently apply to ILE RPG,

Note:
You cannot display return values because there is no external name available for use with the EVAL debug command.

The easiest way to display data or an expression is to use F11 (Display variable) on the Display Module Source display. To display a field using F11 (Display variable), place your cursor on the field that you want to display and press F11 (Display variable). The current value of the field is shown on the message line at the bottom of the Display Module Source display.

In cases where you are evaluating structures, records, 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.

To display data using the EVAL debug command, type:

EVAL field-name

on the debug command line. The variable field-name is the name of the field, data structure, or array that you want to display or evaluate. The value 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, it is shown on the Evaluate Expression display.

Figure 122 shows an example of using the EVAL debug command to display the contents of a subfield LastName.

Figure 122. Displaying a Field using the EVAL debug command
                             Display Module Source
 Program:   DEBUGEX        Library:   MYLIB          Module:   DBGEX
     61       D  LastName                     10A   INZ('Jones    ')
     62       D  FirstName                    10A   INZ('Fred     ')
     63
     64        *---------------------------------------------------------------
     65        * Define prototypes for called procedures c_proc and switch
     66        *---------------------------------------------------------------
     67       D c_proc          PR              *   EXTPROC('c_proc')
     68       D   size                        10U 0 VALUE
     69       D   inzval                       1A   CONST
     70
     71       D Switch          PR
     72       D   Parm                         1A
     73
     74        *---------------------------------------------------------------
     75        * Define parameters for non-prototyped call
                                                                        More...
 Debug . . .   eval LastName____________________________________________________
_______________________________________________________________________________
 F3=End program   F6=Add/Clear breakpoint   F10=Step   F11=Display variable
 F12=Resume       F17=Watch variable   F18=Work with watch   F24=More keys
 LASTNAME = 'Jones     ' 

Figure 123 shows the use of the EVAL command with different types of RPG fields. The fields are based on the source in Figure 131. Additional examples are also provided in the source online help.

Figure 123. Sample EVAL commands based on Module DBGEX
Scalar Fields                             RPG Definition
> EVAL String                             6A   INZ('ABCDEF')
  STRING = 'ABCDEF'
> EVAL Packed1D0                          5P 2 INZ(-93.4)
  PACKED1D0 = -093.40
> EVAL ZonedD3D2                          3S 2 INZ(-3.21)
  ZONEDD3D2 = -3.21
> EVAL Bin4D3                             4B 3 INZ(-4.321)
  BIN4D3 = -4.321
> EVAL Int3                               3I 0 INZ(-128)
  INT3 = -128
> EVAL Int5                               5I 0 INZ(-2046)
  INT5 = -2046
> EVAL Int10                             10I 0 INZ(-31904)
  INT10 = -31904
> EVAL Int20                             20I 0 INZ(-463972)
  INT20 = -463972
> EVAL Unsigned3                          3U 0 INZ(128)
  UNSIGNED3 = 128
> EVAL Unsigned5                          5U 0 INZ(2046)
  UNSIGNED5 = 2046
> EVAL Unsigned10                        10U 0 INZ(31904)
  UNSIGNED10 = 31904
> EVAL Unsigned20                        20U 0 INZ(463972)
  UNSIGNED20 = 463972
> EVAL DBCSString                         3G   INZ(G'~BBCCDD~')
  DBCSSTRING = '"BBCCDD"'
> EVAL NullPtr                             *   INZ(*NULL)
  NULLPTR = SYP:*NULL
Based Fields
> EVAL String                             6A   INZ('ABCDEF')
  STRING = 'ABCDEF'
> EVAL BasePtr                             *   INZ(%ADDR(String))
  BASEPTR = SPP:C01947001218
> EVAL BaseString                         6A   BASED(BasePtr)
  BASESTRING = 'ABCDEF'
Date, Time, Timestamp Fields
> EVAL BigDate                             D   INZ(D'9999-12-31')
  BIGDATE = '9999-12-31'
> EVAL BigTime                             T   INZ(T'12.00.00')
  BIGTIME = '12.00.00'
> EVAL BigTstamp                           Z   INZ(Z'9999-12-31-12.00.00.000000
  BIGTSTAMP = '9999-12-31-12.00.00.000000'


[ Top of Page | Previous Page | Next Page | Contents | Index ]