Purpose |
Removes leading and trailing characters or substrings. |
Syntax |
NewString$ = TRIM$(OldString$ [, [ANY] CharsToTrim$]) NewString$ = TRIM$(NumrExpr [,Digits&]) |
Remarks |
TRIM$ combines the functionality of LTRIM$ and RTRIM$ into a single function. OldString$ is the string expression from which to remove characters, and CharsToTrim$ is the string expression to remove leading and trailing occurrences. If CharsToTrim$ is not specified, TRIM$ removes leading and trailing spaces. |
ANY |
If the ANY keyword is included, CharsToTrim$ specifies a list of single characters to be searched for individually, a match on any one of which as a leading or trailing character will cause the character to be removed from the result. |
NumrExpr |
If a numeric expression is provided as the parameter, it is converted to a string (just like STR$), but with no leading or trailing spaces. |
digits& |
The maximum number of significant digits, in the range of 1 to 18. If not included, PowerBASIC supplies a default value of 7 for single precision values, or 16 for more precise values. Use care that digits& is large enough to contain the integral part of a number, or scientific notation must be used to estimate it. For example, TRIM$(123.456, 2) returns "1.2E+2", while FORMAT$(123.456, 5) returns the string "123.45". |
Restrictions |
TRIM$ is case sensitive, so capitalization matters. |
See also |
CLIP$, FORMAT$, INSTR, LCASE$, LTRIM$, MCASE$, MID$, REMOVE$, REPLACE, RIGHT$, RTRIM$, SHRINK$, TALLY, UCASE$, UNWRAP$, VERIFY |