CHANGE Statement

Replaces a substring with a new substring.

This statement is provided for compatibility with other MultiValue systems.

Syntax

CHANGE oldSubstr TO newSubstr IN varString{, count{, startOccur}})

Syntax Elements

oldSubstr The substring to be changed.

newSubstr The replacement substring.

varString A variable or an element in a dimensioned array containing the string to change. On return, this will contain the modified string.

Note

varString cannot be an element in a dynamic array, nor a substring reference.

count The number of occurrences of oldSubstr to replace with newSubstr. If omitted or less than 1, all occurrences are replaced.

startOccur The number of the first occurrence to replace. If omitted or less than 1, the first occurrence is assumed.

Comments

The parameters oldSubstr and newSubstr can be any expressions that evaluate to strings.

varString must be a variable containing the string to be changed. Note that the contents of this variable are modified by the CHANGE statement.

Case Insensitivity

If data case insensitive mode is selected (see Case Sensitivity), case is ignored when searching varString for oldSubstr.

See Also

CHANGE function.

Examples

MYSTR = "IRVINE, CA 92714"
A = "92714"
B = "92720"
CHANGE A TO B IN MYSTR

Replaces substring A (92714) in MYSTR with substring B (92720). On completion, MYSTR contains IRVINE, CA 92720.

X = "31AA42BB53AAA"
Y = "AA"
Z = "CC"
CHANGE Y TO Z IN X

Changes the contents of variable X from "31AA42BB53AAA" to "31CC42BB53CCA".

X = "31AA42BB53AAA"
Y = "AA"
Z = "CC"
CHANGE Y TO Z IN X, 1

Changes the contents of variable X from "31AA42BB53AAA" to "31CC42BB53AAA". The second occurrence of "AA" is not changed because only one occurrence is changed.

X = "31AA42BB53AAA"
Y = "AA"
Z = "CC"
CHANGE Y TO Z IN X, 0, 2

Changes the contents of variable X from "31AA42BB53AAA" to "31AA42BB53CCA". The first occurrence of "AA" is not changed because replacement starts at the second occurrence.