MAXLENGTH Function

Purpose

Returns the maximum length of a string.

Syntax

MAXLENGTH(x)

Parameters

x is an expression that must have a computational type and should have a string type. Otherwise, it is converted to character.

Description

The precision of the result is Fixed Binary(15) unless the -bifprec compiler option overrides it.

Examples

dcl s char (40) varying;
    dcl t char (40) ;

    s = 'The Lawn, 22-30 Old Bath Road';

    put skip list ('maxlength(s) is: ', maxlength(s));   /* char var */
    put skip list ('maxlength(t) is: ', maxlength(t));   /* char       */

will print:

maxlength(s) is:               40
maxlength(t) is:               40

Restrictions

None.