TRIM

Transformational Intrinsic Function (Generic): Returns the argument with trailing blanks removed.

Syntax

result = TRIM (string)

string
(Input) Must be a scalar of type character.

Results:

The result is of type character with the same kind parameter as string. Its length is the length of string minus the number of trailing blanks in string.

The value of the result is the same as string, except any trailing blanks are removed. If string contains only blank characters, the result has zero length.

Compatibility

CONSOLE STANDARD GRAPHICS QUICKWIN GRAPHICS WINDOWS DLL LIB

See Also: LEN_TRIM

Examples

In these examples, the symbol - represents a blank.

TRIM ('--NAME----') has the value '--NAME'.

TRIM ('--C--D-----') has the value '--C--D'.

The following shows another example:

 ! next line prints 28
 WRITE(*, *) LEN("I have blanks behind me       ")
 ! the next line prints 23
 WRITE(*,*) LEN(TRIM("I have blanks behind me       "))
 END