Skip to main content

This is documentation for Caché & Ensemble.

For information on converting to InterSystems IRIS, see the InterSystems IRIS Adoption Guide and the InterSystems IRIS In-Place Conversion Guide, both available on the WRC Distributions page (login required).

Previous sectionNext section


Returns the length of each element of a dynamic array.




dynarray An expression that resolves to a dynamic array.


The LENS function returns the number of characters in each element of a dynamic array. LENS counts characters, not bytes. Results are returned as a dynamic array of integers.

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 LENS does count the decimal point and the minus sign. Numeric strings are not converted to canonical form. An empty string ("") or a missing element returns a length of 0 for that element.


The following example uses the LENS function to return the number of characters in each element of a dynamic array. Numbers are converted to canonical form:

PRINT LENS(nums);  ! Returns 3ý4ý3ý7ý0
Copy code to clipboard

The following example show how LENS handles missing dynamic array elements:

PRINT LENS(nums);  ! Returns 3ý3ý0ý3
Copy code to clipboard

See Also