Using Debug Built-In Functions

The following built-in functions are available while using the ILE source debugger:

%SUBSTR
Substring a string field.
%ADDR
Retrieve the address of a field.
%INDEX
Change the index of a table or multiple-occurrence data structure.
%VARS
Identifies the specified parameter as a variable.

The %SUBSTR built-in function allows you to substring a string variable. The first parameter must be a string identifier, the second parameter is the starting position, and the third parameter is the number of single-byte or double-byte characters. In addition. the second and third parameters must be positive, integer literals. Parameters are delimited by one or more spaces.

Use the %SUBSTR built-in function to:

Figure 128 shows some examples of the use of %SUBSTR based on the source in Figure 131.

Figure 128. Examples of %SUBSTR using DBGEX
 > EVAL String
   STRING = 'ABCDE '
** Display the first two characters of String **
 > EVAL %substr (String 1 2)
   %SUBSTR (STRING 1 2) = 'AB'
 > EVAL TableA
   TABLEA = 'aaa'
** Display the first character in the first table element **
 > EVAL %substr(TableA 1 1)
   %SUBSTR(TABLEA 1 1) = 'a'
 > EVAL BigDate
   BIGDATE = '1994-10-23'
** Set String equal to the first four characters of BigDate **
 > EVAL String=%substr(BigDate 1 4)
   STRING=%SUBSTR(BIGDATE 1 4) = '1994  '
 > EVAL Fld1           (5 characters)
   FLD1 = 'ABCDE'
 > EVAL String         (6 characters)
   STRING = '123456'
** Set the characters 2-5 of String equal to the
                 first four characters of Fld1 **
 > EVAL %substr(String 2 4) = %substr(Fld1 1 4)
   %SUBSTR(STRING 2 4) = %SUBSTR(FLD1 1 4) = 'ABCD'
 > EVAL String
   STRING = '1ABCD6'
** You can only use %SUBSTR on character or graphic strings! **
 > EVAL %substr (Packed1D0 1 2)
   String type error occurred.

To change the current index, you can use the %INDEX built-in function, where the index is specified in parentheses following the function name. An example of %INDEX is found in the table section of Figure 125 and Figure 126.

Note:
%INDEX will change the current index to the one specified. Therefore, any source statements which refer to the table or multiple-occurrence data structure subsequent to the EVAL statement may be operating with a different index than expected.

Use the %VARS debug built-in function when the variable name conflicts with any of the debug command names. For example, EVAL %VAR(EVAL) can be used to evaluate a variable named EVAL, whereas EVAL EVAL would be a syntax error.



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