convert Statement

The convert statement searches a given variable and replaces each occurrence of a character by another.

Syntax

convert str.exp1 to str.exp2 in var

Parameter(s)

var

Variable in which the specified string will be searched and replaced.

str.exp1  

Specifies the characters to be replaced with the corresponding replacement characters from str.exp2.

str.exp2  

Specifies the characters to replace the characters specified in str.exp1.

Description

Any character designated in str.exp1 is replaced with the corresponding replacement character from str.exp2. The correspondence is by column position in str.exp1 and str.exp2.

If the length of str.exp1 is shorter than str.exp2, all characters in str.exp2 beyond the length of str.exp1 are ignored.

If the length of str.exp1 is longer than str.exp2, all characters in str.exp1 beyond the length of str.exp2 are deleted from var.

Example(s)

All attribute marks are replaced with spaces in the variable text.str.

convert char(254) to " " in text.str

This converts the attribute marks in text.item to linefeed characters.

equ am to char(254)

convert am to char(10) in text.item

This outputs "d".

x = "abc"

convert "abc" to "d" in x ; crt x

This outputs "a".

x = "d"

convert "d" to "abc" in x ; crt x

This outputs zmmz.

x = "abba"

convert "ab" to "zm" in x ; crt x

See Also

convert() Function

Statements and Functions

u009e User Exit

Variables