TRIMLEN: Determining the Length of a String Excluding Trailing Spaces

How to:

The TRIMLEN function determines the length of a character string excluding trailing spaces.


Top of page

x
Syntax: How to Determine the Length of a String Excluding Trailing Spaces
TRIMLEN (string)

where:

string

Alphanumeric

Is the string to be measured.



Example: Determining the Length of a String Excluding Trailing Spaces

TRIMLEN determines the length of a field in COUNTRY excluding trailing blanks:

MAINTAIN FILE CAR
MODULE IMPORT (MNTUWS)
NEXT COUNTRY INTO STK1
COMPUTE LEN/I3 = LENGTH(STK1(1).COUNTRY);
COMPUTE LEN2/I3 = TRIMLEN(STK1(1).COUNTRY);
TYPE "<STK1(1).COUNTRY  HAS A LENGTH OF <LEN2  WITHOUT TRAILING BLANKS"
END

The result is:

ENGLAND HAS A LENGTH OF 7 WITHOUT TRAILING BLANKS

Information Builders