MAXLENGTH
MAXLENGTH returns the maximum length of a string.
- x
- Expression. x must have a computational type and should have a string type. If not, it is converted to character.
Example
dcl x char(20);
dcl y char(20) varying;
x, y = '';
x = copy( '*', length(x) ); /* fills x with '*' */
y = copy( '*', length(y) ); /* leaves y unchanged */
x = copy( '-', maxlength(x) ); /* fills x with '-' */
y = copy( '-', maxlength(y) ); /* fills y with '-' */
Note that the first assignment to y leaves it unchanged because length(y) will return zero when it is used in the code snippet above (since y is VARYING and was previously set to '').
However, the second assignment to y fills it with 20 - signs because maxlength(y) will return 20 (the declared length of y).