Ü  SUBST (Substring)

               

·        The SUBST operation returns a substring from factor 2, starting at the location specified in factor 2 for the length specified in factor 1, and places this substring in the result field.

·        If factor 1 is not specified, the length of the string from the start position is used.

   

Factor 1

Op-code

Factor 2

Result Field

Resulting Indicators

       HI                            LO                      EQ

Length to be extracted

SUBST(E P)

Source string: starting postion

Target string

Error Indicator

 

 

Example

 


Columns . . . :    6  80                  Browse                              AMINEM/QRPGLESRC
SEU==>                                                                               OP_SUBST
FMT D  DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords+++++++++++++++++++++++++++++
*************** Beginning of data ****************************************************
0001.00 D string          S             30A   inz ('Search string')                     130130
0002.00 D substring       S             30A   inz (*blanks)                             130130
0003.00 D pos             S              5U 0                                           130110
0004.00 D len             S              5U 0                                           130130
0005.00 D restlen         S              5U 0                                           130130
0006.00                                                                                 130110
0007.00 C                   EVAL      len=%len (string)                                 130130
0008.00 C     ' '           SCAN      string        pos                                 130130
0009.00 C     pos           SUBST     string:1      substring                           130130
0010.00 C     substring     DSPLY                                                       130130
0011.00 C                   EVAL      restlen=len-pos                                   130130
0012.00 C                   EVAL      pos=pos+1                                         130130
0013.00 C     restlen       SUBST     string:pos    substring                           130130
0014.00 C     substring     DSPLY                                                       130130
0015.00 C                   SETON                                        LR             130110
****************** End of data *******************************************************


 

OUTPUT

 

DSPLY  Search     

DSPLY  string     

 

 











User Comments:



Subscribe

.  


Copyright © www.go4as400.com, 2013-2023. Copyright notice   Terms of services   Privacy policy