STRTRIM function returns a copy of
with leading and/or trailing blanks removed.
Result = STRTRIM(
The string to have leading and/or trailing blanks removed. If this argument is not a string, it is converted using IDL's default formatting rules. If it is an array, the result is an array with the same structure where each element contains a trimmed copy of the corresponding element of
A value that controls the action of STRTRIM. If
is zero or not present, trailing blanks are removed. Leading blanks are removed if it is equal to 1. Both are removed if it is equal to 2.
Converting variables to string type often results in undesirable leading blanks. For example, the following command converts the integer 56 to string type:
C = STRING(56)
Entering the command:
C STRING = ' 56'
which shows that there are six leading spaces before the characters 5 and 6. To remove these leading blanks, enter the command:
C = STRTRIM(C, 1)
To confirm that the blanks were removed, enter:
C STRING = '56'