Scripting > UNICOM Intelligence Function Library > Miscellaneous functions > Replace
 
Replace
Replaces part of a text or categorical value with another value of the same type.
Syntax
Replace(Val, Key, Replacement [, Start [, Count [, IgnoreCase]]])
Parameters
Val
Type: None
Variant value of type Text or Categorical.
Key
Type: None
Variant value to look for in Val, of the same type as Val.
Replacement
Type: None
Variant value with which to replace Key, of the same type as Val.
Start
Type: Long
Optional. Position in Val (starting from 0), from which to start searching for Key. If omitted or less than 0, searching starts at the start of Val.
Count
Type: Long
Optional. Maximum number of replacements to make. If omitted or less than 0, all possible replacements are made.
IgnoreCase
Type: Boolean
Optional. Whether to do case-insensitive comparison for Key. The default is False.
(return)
Type: None
Copy of Val with Key replaced with Replacement.
Remarks
If Val is of type Text, Key and Replacement are converted to text values, unless they are already text values or NULL. If Val is of type Categorical, Key and Replacement are converted to categorical values, unless they are already categorical values or NULL. An error occurs if Key or Replacement cannot be converted to the required type.
If Val is NULL, the return value is NULL. If Key is NULL, no replacements are made. If Replacement is NULL, occurrences of Key are removed instead of being replaced. If Val is of any other type, an error occurs.
Examples
The following mrScriptBasic example shows the use of the Replace function to replace all the hyphens in a text variable with spaces.
strVal = strVal.Replace("-", " ")
See also
Miscellaneous functions