Please enable JavaScript to view this site.

R:BASE 11 Help

Navigation: Function Index > S

SLOC

Scroll Prev Top Next More

(SLOC(text,string))

 

Locates string in text, returning the position if the string is found, 0 if it is not found.

In the following example, the value of vsloc1 is 3.

 

SET VAR vsloc1 = (SLOC('ABCDE','C'))

 

The value of vsloc2 in the following example is 0, since the text string X does not exist in the text string ABCDE.

 

SET VAR vsloc2 = (SLOC('ABCDE','X'))

 

In the following example, the custzip column contains a customer's zip code, in which the first five characters might be followed by a dash and another four characters. If the first row contained the string 02178-5243, Sloc3 would capture the position of the dash (6), which is in the sixth position.

 

SET VAR v5zip = custzip IN customer WHERE COUNT = 1

SET VAR sloc3 = (SLOC(.v5zip,'-'))