EXCHANGE function

Syntax

EXCHANGE (string, xx, yy)

Description

Use the EXCHANGE function to replace one character with another or to delete all occurrences of the specified character.

string is an expression evaluating to the string whose characters are to be replaced or deleted. If string evaluates to the null value, null is returned.

xx is an expression evaluating to the character to be replaced, in hexadecimal notation.

yy is an expression evaluating to the replacement character, also in hexadecimal notation.

If yy is FF, all occurrences of xx are deleted. If xx or yy consist of fewer than two characters, no conversion is done. If xx or yy is the null value, the EXCHANGE function fails and the program terminates with a run-time error message.

Note: 0x80 is treated as @NULL.STR, not as @NULL.

If NLS is enabled, EXCHANGE uses only the first two bytes of xx and yy in order to evaluate the characters. Note how the EXCHANGE function evaluates the following characters:

Bytes...
Evaluated as...
00 through FF
00 through FF
00 through FA
Unicode characters 0000 through FA
FB through FE
System delimiters

Example

In the following example, 41 is the hexadecimal value for the character A and 2E is the hexadecimal value for the period character ( . ):

PRINT EXCHANGE('ABABC','41','2E')

This is the program output:

.B.BC