2. Writing Scripts and Procedures : How Procedure Handles Work (ProcHandle Objects) : Global Procedures Available in the Core Library : The _StringTokenSub Procedure
 
Share this page                  
The _StringTokenSub Procedure
This procedure substitutes a value for the specified token in a string. The syntax for this procedure is:
varchar(2000) =_StringTokenSub(string=varchar(2000),
              token=varchar(256),
              replacewith=varchar(256)
              [remainingtokens=byref(integer)]);
The optional argument remainingtokens, if specified, is set to the number of occurrences of tokens that remain in the string after the substitution.
The following example shows how to use the _StringTokenSub procedure:
str1 = _StringTokenSub(string='Employee Name:John Doe, Address: 101 California, USA (c/o John Doe)', token = 'John Doe', replacewith='Jane Doe', remaingtoken=byref(icount));
This example returns “Employee Name:Jane Doe, Address:101 California, USA (c/o John Doe)”. The icount variable contains 1, indicating that there is one more occurrence of John Doe in the substituted string.