Caché MultiValue Basic Reference
FIELDSTORE
[Back] [Next]
   
Server:docs1
Instance:LATEST
User:UnknownUser
 
-
Go to:
Search:    

Replaces data in a delimited string.
Synopsis
FIELDSTORE(string,delimiter,count,multiple,newval)
Arguments
string An expression that resolves to a string. The source string to be modified. string can be a dynamic array.
delimiter An expression that resolves to a single character that serves as a delimiter within string
count An expression that resolves to an integer that specifies which delimited string to use as the starting point for the replacement operation.
multiple An expression that resolves to an integer specifying how many delimited strings to replace with newval.
newval An expression that resolves to a string. The data to be inserted.
Description
The FIELDSTORE replaces one or more delimited substrings in string with a specified newval, then returns the resulting string. The source string remains unchanged. FIELDSTORE adds and removes delimiters as needed.
If delimiter is not found in string, and count is 1, 0, or the null string, newval replaces string and is returned with no delimiters. If delimiter is not found in string, and count is > 1, the specified delimiter and newval are appended to string. The number of delimiters appended being count minus 1.
Examples
The following example uses the FIELDSTORE function to return a string that replaces the first delimited substring in the string:
cities="New York^London^Chicago^Boston^Los Angeles"
PRINT FIELDSTORE(cities,"^",1,1,"Providence")
    ! Returns: "Providence^London^Chicago^Boston^Los Angeles"
The following example uses the FIELDSTORE function to return a string that replaces the second Value Mark delimited substring in the dynamic array:
cities="New York":@VM:"London":@VM:"Chicago":@VM:"Boston":@VM:"Los Angeles"
PRINT cities
    ! Returns: "New YorkýLondonýChicagoýBostonýLos Angeles"
PRINT FIELDSTORE(cities,CHAR(253),2,1,"Providence")
    ! Returns: "New YorkýProvidenceýChicagoýBostonýLos Angeles"
The following example uses the FIELDSTORE function to replace the second Value Mark delimited substring and the next two substrings in a dynamic array:
cities="New York":@VM:"London":@VM:"Chicago":@VM:"Boston":@VM:"Los Angeles"
PRINT cities
    ! Returns: "New YorkýLondonýChicagoýBostonýLos Angeles"
PRINT FIELDSTORE(cities,CHAR(253),2,3,"Providence")
    ! Returns: "New YorkýProvidenceýLos Angeles"
See Also