xcall TRIM, strvar {,flag}
TRIM.SBR removes both leading and trailing blanks from the specified string variable. In addition, it can optionally remove other non-printable characters.
Parameters
strvar [in]
is the string variable from which you want to trim the leading and trailing spaces. It does not need a trailing null byte.
flag (Num) [in]
may be specified as any non-zero value to cause TRIM to treat any characters with ASCII values less than 32 (space) or greater than 127 the same as space (i.e. remove them). Like spaces, they must still be prior to the first printable character or after the last one, and prior to the first null, to be removed. Any spaces or other control characters that are embedded between printable characters are left alone.
Comments
The EDIT$() function supports the ability to remove certain types of characters within (rather than just at the beginning or end of) the string.
The SBR=TRIMCTL setting in the system parameters file forces TRIM to act as if a nonzero flag value had been passed.
TRIM.SBR is actually a wrapper for STRIP.SBR with which it communicates by setting up a dummy second parameter. The problem is that the way it was done has the effect of updating the actual parameter passed. Users are advised that the flag parameter may be overwritten, and should therefore probably be expressed as a literal value (or in new programs, using a defined constant rather than a variable, i.e. define TRUE=-1 rather than MAP1 TRUE,F,6,-1).