LEN

Inquiry Intrinsic Function (Generic): Returns the length of a character expression.

Syntax

result = LEN (string [, kind])

string
(Input) Must be of type character; it can be scalar or array valued. (It can be an array of strings.)

kind
(Optional; input) Must be a scalar integer initialization expression.

Results:

The result is a scalar of type integer. If kind is present, the kind parameter of the result is that specified by kind; otherwise, the kind parameter of the result is that of default integer. If the processor cannot represent the result value in the kind of the result, the result is undefined.

The result has a value equal to the number of characters in string (if it is scalar) or in an element of string (if it is array valued).

The setting of compiler options that specify integer size can affect the result of this function.

Specific Name Argument Type Result Type
LEN CHARACTER INTEGER(4)
  CHARACTER INTEGER(8)

Compatibility

CONSOLE STANDARD GRAPHICS QUICKWIN GRAPHICS WINDOWS DLL LIB

See Also: LEN_TRIM

Examples

Consider the following example:

  CHARACTER (15) C (50)
  CHARACTER (25) D

LEN (C) has the value 15, and LEN (D) has the value 25.

The following shows another example:

CHARACTER(11) STR(100)
INTEGER I
I = LEN (STR)  ! returns 11
I = LEN('A phrase with 5 trailing blanks. ')
               ! returns 37