Ü  %SCAN (search argument : source string {: start})

·         It is used to find the first occurrence position of search string.

 

Example –%scan built-in function in rpgle

 


Columns . . . :    6  80              Browse                          AMIT/QRPGLESRC
SEU==>                                                                     SCAN_RPG
FMT D  DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords+++++++++++++++++++++++++++++
*************** Beginning of data **********************************
0001.00 D searchstring    S             30A   inz ('Search string')
0002.00 D substring       S             30A   VARYING
0003.00 D pos             S              5U 0
0004.00 D len             S              5U 0
0005.00
0006.00  /FREE
0007.00     len = %scan ('   ' : searchstring);       //len value = length of searchstring
0008.00     DSPLY  len;
0009.00     pos = %scan (' ' : searchstring);         //pos value = 7
0010.00     substring=%subst (searchstring:1:pos);    //substring = ‘Search’
0011.00     DSPLY  substring;
0012.00     substring=%subst (searchstring:pos+1:len); //substring = string
0013.00     DSPLY  substring;
0014.00  /END-FREE
0015.00 C                   SETON                                        LR
****************** End of data ***********************************************

 

 

 

Output

DSPLY     14

DSPLY  Search     

DSPLY  string                         

 










User Comments:



Subscribe

  Email:



Copyright © Go4as400.com, 2013-2017. Copyright notice