TRIM

TRIM(string_value [ ,flag ] )

string_valueThe string from which to remove spaces.
flagOptional. Specify which spaces to remove. Valid flag values are:

RIGHT (remove trailing spaces--this is the default)

LEFT (remove leading spaces)

LEFT, RIGHT (remove leading and trailing spaces)

ALL (remove all spaces, even those within the string_value)

WHITESPACE Used in conjunction with any of the other flags, this removes ALL white space characters from the specified area. If omitted, only the space character (0x20) is removed.

Return:TRIM returns a single value.

The TRIM function returns the string_value with all trailing and/or leading spaces (0x20) removed.

The WHITESPACE option removes all white space characters. In STRING, this is space (0x20), horizontal tab, vertical tab, line feed, form feed, carriage return (0x09 to 0x0D), and non-breaking space (0xA0). For UNICODE, it removes all characters with the white space property.

Example:

STRING20 MyString1 := 'ABC';
                    //contains 17 trailing spaces
VARSTRING MyTrimmedVarString1 := TRIM(MyString1);
                   // MyVal is "ABC" with no trailing spaces
STRING20 MyString2 := ' ABC DEF';
                   //contains 2 leading and 11 trailing spaces
VARSTRING MyTrimmedVarString2 := TRIM(MyString2,LEFT,RIGHT);
                   // MyVal is "ABC DEF" with no trailing spaces
OUTPUT(MyString1);
OUTPUT(MyTrimmedVarString1);
OUTPUT(MyString2);
OUTPUT(MyTrimmedVarString2);

See Also: STRING, VARSTRING