Gets the maximum defined length of a string variable.

MaxLength := MAXSTRLEN(String)

Parameters

String

Type: Text constant or code

The string variable for which you want to find the maximum length.

Property Value/Return Value

Type: Integer

The maximum length of the string variable.

Remarks

If you call this function on a Variant, it returns an error.

Example

This example requires that you create the following variables and text constants in the C/AL Globals window.

Variable name DataType Length

City

Text

30

MaxLength

Integer

Not applicable

Length

Integer

Not applicable

Text constant ENU value

Text000

Vedbaek

Text001

The MAXSTRLEN function returns %1,\

Text002

whereas the STRLEN function returns %2

Copy Code
City := Text000;
MaxLength := MAXSTRLEN(City);
Length := STRLEN(City);
MESSAGE(Text001 + Text002, MaxLength, Length);

The message window displays the following:

The MAXSTRLEN function returns 30,

whereas the STRLEN function returns 7.

See Also