Returns the length of a string you define.
Parameters
- String
-
Type: Text constant or code
The string for which you want to determine the length.
Property Value/Return Value
Type: Integer
The length of String.
Remarks
Example
This example shows the difference between the STRLEN
and the MAXSTRLEN functions. Assume the variable City was defined
with a maximum length of 30 characters.
This example requires that you create the following
text constants in the C/AL Globals window.
Text constant |
ENU value |
Text000
|
'Atlanta'
|
Text001
|
'The MAXSTRLEN function returns: %1,\'
|
Text002
|
'while 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
while the STRLEN function returns: 7
This shows that the MAXLENGTH function returns the
maximum possible length according to the definition of the string
variable, while STRLEN returns the actual length of the text.
See Also