Skip to main content

LEN

Returns the number of characters in a string.

Synopsis

LEN(string)

Arguments

string An expression that resolves to a string or numeric expression.

Description

The LEN function returns the number of characters in a specified string. LEN counts characters, not bytes. You can use the BYTELEN function to count the number of bytes in a string.

For numerics, prior to determining the length MVBasic performs all arithmetic operations and converts numbers to canonical form, with leading and trailing zeroes, a trailing decimal point, and all signs removed except a single minus sign. Note that LEN does count the decimal point and the minus sign. Numeric strings are not converted to canonical form. An empty string ("") returns a length of 0.

Examples

The following example uses the LEN function to return the number of characters in a string:

PRINT LEN("InterSystems");  ! Returns 12
PRINT LEN(+0099.900);       ! Returns 4
PRINT LEN("0099.900");      ! Returns 8
PRINT LEN(CHAR(960));       ! Returns 1
PRINT LEN("");              ! Returns 0

See Also

FeedbackOpens in a new tab