translate
Translates a character string.
Available in:
| Apps (win) |
Apps (char) |
Reportwriter |
RPC |
Standalone PL |
| X |
X |
X |
X |
X |
Syntax
string translate(data,from,to)
string data,from,to
Description
Replaces all characters in data as specified.
If the number of characters in to is a multiple of the number
of characters in from, for each character in from,
that multiple of characters from to replaces that
single character.
If to is empty, all characters found in from are deleted.
|
data | specifies the string to translate.
|
|
from | specifies the characters to replace.
|
|
to | specifies new characters to use.
|
Example
Replaces all digits with asterisk (*).
field = translate(SAL,"0123456789","**********");
Replaces all single quotes with two single quotes (useful for SQL INSERT
commands).
exec_sql(translate(sqlstmt,"'","''"));
Deletes all commas from character representation of numerics.
buf = translate(line,",","");
Validates that a string contains only uppercase letters.
if (translate(line,"ABCDEFGHIJKLMNOPQRSTUVWXYZ","") != "")
error("Line may only contain letters");