STRTRIM Function

Removes extra blank spaces from an input string.

Usage

result = STRTRIM(string[, flag])

Input Parameters

string—The string that will have leading and/or trailing blanks removed.

If not of type string, string is converted to string using the default formatting rules of PV‑WAVE. (These rules are described in the PV‑WAVE Programmer’s Guide.)

flag—Controls the action of STRTRIM:

If zero or not present, removes trailing blanks.

If 1, removes leading blanks.

If 2, removes both leading and trailing blanks.

Returned Value

result—A copy of string with extra (leading and/or trailing) blank spaces removed. If string is an array, the result is an array with the same structure—each element contains a trimmed copy of the corresponding element of string.

Keywords

None.

Example

In this example, STRTRIM is used to trim trailing, leading, then trailing and leading blanks from a string.

; Create a string with both leading and trailing blanks.
a = '    A String   '
; Examine the contents of a. Note the presence of both leading and
; trailing blanks.
INFO, a
; PV-WAVE prints: VARIABLE          STRING    = '    A String   '
; Remove trailing blanks from a.
b = STRTRIM(a)
INFO, b
; PV-WAVE prints: VARIABLE       STRING    = '    A String'
; Note that all trailing blanks are removed.
; Remove leading blanks from a.
b = STRTRIM(a, 1)
INFO, b
; PV-WAVE prints: VARIABLE          STRING    = 'A String   '
; Examine the results. Note that all leading blanks are removed.
; Remove both leading and trailing blanks from a.
b = STRTRIM(a, 2)
INFO, b
; PV-WAVE prints: VARIABLE           STRING    = 'A String'
; Note that all leading and trailing blanks are removed.

See Also

STRCOMPRESS