IBM AS/400 manual Stepping Through the Program Object, Examples of %SUBSTR using DBGEX

Models: AS/400

1 489
Download 489 pages 47.95 Kb
Page 231
Image 231
Figure 102. Examples of %SUBSTR using DBGEX

Stepping Through the Program Object

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

Use the %SUBSTR built-in function to:

¹ Display a portion of a character field

¹ Assign a portion of a character field

¹Use a portion of a character field on either side of a condi expression.

Figure 102

shows some examples of the use of %SUBSTR based on the s

Figure 105

on page 212.

>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.

Figure 102. Examples of %SUBSTR using DBGEX

To change the current index, you can use the %INDEX built-in function index is specified in parentheses following the function name. An exa %INDEX is found in the table section of Figure 99 on page 203 and Fig page 204.

Note: %INDEX will change the current index to the one specified. The source statements which refer to the table or multiple-occurrenc ture subsequent to the EVAL statement may be operating with a index than expected.

Chapter 11. Debugging Programs207

Page 231
Image 231
IBM AS/400 manual Stepping Through the Program Object, Examples of %SUBSTR using DBGEX, Debugging Programs207