trimlen(3F)
TRIMLEN - Returns the length of a character argument without counting trailing blanks
As shipped in IRIX 6.5.22. Last changed in IRIX 6.5.19.
NAME TRIMLEN - Returns the length of a character argument without counting trailing blanks SYNOPSIS INTEGER trimlen intlen = TRIMLEN(string) DESCRIPTION TRIMLEN is an integer function that returns the length of a character argument without counting the trailing blanks. The function must be declared as type integer in the calling routine. The string argument must be of type character. This function is intended for use as part of the substring notation. Examples 2 and 3 show the TRIMLEN function used in this manner. The value of each of the parts of the substring notation must be as follows: 1 <= leftmostpos <= rightmostpos <= stringlength leftmostpos is the leftmost character position in the substring, rightmostpos is the rightmost character position in the substring, and stringlength is the declared length of the character entity. TRIMLEN returns a value of 1 for a string of all blanks. EXAMPLES Example 1: A program using the function TRIMLEN could do the following: INTEGER TRIMLEN CHARACTER*80 STRING STRING = ' ' STRING(20:47) = 'TEST TRIMLEN LENGTH RETURNED' INTLEN = TRIMLEN(STRING) WRITE(6,1) INTLEN, STRING(1:INTLEN) 1 FORMAT(' LENGTH=',I5,' STRING=',A,'-DONE') PRINT 2,'12345678901234567890123456789012345678901234567890' 2 FORMAT(21X,A) END The output of the program is as follows: LENGTH= 47 STRING= TEST TRIMLEN LENGTH RETURNED-DONE 12345678901234567890123456789012345678901234567890 Example 2: This example produces a string with the character < written following the last nonblank character of STRING: WRITE(6,901)STRING(1:TRIMLEN(STRING)) 901 FORMAT(' The string is >',A,'<') Example 3: In this example, although NEW may have trailing blanks, the character < is written after the last nonblank character in STRING: NEW = STRING(1:TRIMLEN(STRING)) // '< The end'