Please enable JavaScript to view this site.

R:BASE 11 Help

Navigation: Function Index > S

SLOCP

Scroll Prev Top Next More

(SLOCP(TextNoteVarcharValue,string,occurrence))

 

Locates the exact position of a given string and occurrence in a TEXT, NOTE or VARCHAR value, returning the position if the string is found, 0 if it is not found. Using -1 as the third parameter will return the LAST occurrence.

 

The resulting variable returns an integer value.

 

In the following example, the position for the first occurrence of AB is 1.

 

SET VARIABLE v1 VARCHAR = 'ABCDEABC_AB'

SET VARIABLE vslocp1 = (SLOCP(.v1,'AB',1))

 

 

In the following example, the position for the second occurrence of AB is 6.

 

SET VARIABLE v1 VARCHAR = 'ABCDEABC_AB'

SET VARIABLE vslocp2 = (SLOCP(.v1,'AB',2))

 

 

To find the LAST occurrence in the value of a string, use the "-1" parameter. In the following example, the position for the last occurrence of AB is 10:

 

SET VARIABLE v1 VARCHAR = 'ABCDEABC_AB'

SET VARIABLE vSLocLast = (SLOCP(.v1,'AB',-1))