Removes blank spaces or another specified character from a string.
TRIM(string{, removeChar{, type}})
TRIMB(string)
TRIMF(string)
string An expression that evaluates to the string to be trimmed.
removeChar The character to be removed from the string. The default, if the removeChar parameter is omitted, is a space.
type A string containing one of the following characters (the default is "R".):
L Removes all leading occurrences of removeChar.
T Removes all trailing occurrences of removeChar.
B Removes both leading and trailing occurrences of removeChar.
A Removes all occurrences of removeChar.
R Removes leading and trailing occurrences of removeChar and replaces multiple consecutive occurrences with a single character.
Only the first character in type is significant; subsequent characters are ignored.
Note: If string comprises removeChar only, the TRIM function trims to a null string.
For example:
X = "AAAA" Y = TRIM(X, "A", "R")
Assigns ' ' to variable Y.
The TRIMB and TRIMF functions are shorthand forms of the TRIM function:
NEW.STR = TRIM(OLD.STR, CHAR(254), 'T')
Removes all trailing attribute marks from OLD.STR and assigns
the new string to NEW.STR
.
X = "@@@BB@@@CC@@@" Y = TRIM(X, "@") PRINT Y
Removes leading and trailing occurrences of "#" and replaces multiple
consecutive occurrences with a single character; prints the string BB@CC
.
STR1 = "1230010029911" X = TRIM(STR1, "1", 'A') PRINT X
Removes all occurrences of the number 1 and prints the
string 230000299
.