close

%SCAN()


search argument : string to be searched {:start position} 
First position of search argument in string or zero, if not found.

There are two very big differences between these two BIFs.

  • The first is that with %CHECK, the compare string is treated as a list of individual characters, whereas %SCAN operates on it as a single string. 
  • The second is that %SCAN tries to locate an occurrence of the characters in the compare string, whereas %CHECK tries to identify any characters that are not present in the compare string.

Remember: The operations are case-sensitive.
 

Example for %SCAN()

D $source         S            100A                   
D $pos            S              5U 0                 
                                                      
 /FREE                                                
                                                      
   $source = 'RPGLE is a Popular Programming ' +      
             'language of the IBM Power i platform';  
                                                      
   $pos = %scan ('IBM' : $source);                    
   dsply $pos; //DSPLY     48                         
                                                      
   $pos = %scan ('IBM' : $source :15);                
   dsply $pos; //DSPLY     48                         
                                                      
   $pos = %scan ('Po' : $source);                     
   dsply $pos; //DSPLY     12                         
                                                      
   $pos = %scan ('Po' : $source : 20);                
   dsply $pos; //DSPLY     52                         
                                                      
    *inlr = *on;                                      
 /END-FREE        
arrow
arrow
    文章標籤
    AS400 RPGLE SCAN
    全站熱搜
    創作者介紹
    創作者 alsan 的頭像
    alsan

    alsan的網誌

    alsan 發表在 痞客邦 留言(0) 人氣()