# DLEN()

Syntax:

Then: a=DLEN(exp)

Version Ref: 4.1

Description:

Returns the display length of a string. This function is useful for aligning or centering data on the screen.

Examples:

Then: aa=3<4 ; show "@ the display length of aa is" < dlen(aa)

Note: If you want the display length of a cast dummy variable, in other words, one that has been given a length and edit type, you must do a small trick to find the real display length. Otherwise, DLEN will return the predefined length of the field, regardless of what data is in the field. To fix this, put nulls around the field and take the DLEN of that expression.

Then: aa(5,.0)="12"/"3" ; show "@ incorrect display length is" < dlen(aa)
Then: show "@ correct display length is" < dlen(""{aa{"")

Instead of displaying 5 as the display length, surrounding the variable with nulls gives a correct result.

Note: DLEN() had an undocumented limit of 255 characters on the input string prior to release 5.0.12. The input is now unlimited, and the output is limited to 4095.