Converts some characters in a string.

NewString := CONVERTSTR(String, FromCharacters, ToCharacters)

Parameters

String

Type: Text constant or code

The string that you want to convert.

FromCharacters

Type: Text constant or code

The characters that you want to replace. This function is case-sensitive.

ToCharacters

Type: Text constant or code

The new characters with which you want to replace the FromCharacters. This function is case-sensitive.

The length of this string must correspond to the length of FromCharacters.

Each character in FromCharacters is replaced with the corresponding character in ToCharacters.

Property Value/Return Value

Type: Text constant or code

The converted string.

Remarks

The characters in the FromCharacters parameter are replaced by the characters in the ToCharacters parameter.

If the lengths of the FromCharacters and ToCharacters strings are not equal, then a run-time error occurs.

If either the FromCharacters or the ToCharacters strings are empty, then the source is returned unchanged.

Example

This example requires that you create the following variables and text constants in the C/AL Globals window.

Variable name DataType Length

OriginalString

Text

30

FromChars

Text

30

ToChars

Text

30

NewString

Text

30

Text constant ENU value

Text000

Do you want to leave without saving?

Text001

lws

Text002

LWS

Text003

The original sentence is:\ %1

Text004

The sentence is converted to:\ %1

 Copy Code
OriginalString := Text000;
FromChars := Text001;
ToChars := Text002; 
NewString := CONVERTSTR(OriginalString, FromChars, ToChars);
MESSAGE(Text003, OriginalString);
MESSAGE(Text004, NewString);

The first message window shows:

The original sentence is:

Do you want to leave without saving?

The second message window shows:

The sentence is converted to:

Do you Want to Leave Without Saving?

See Also