Caché MultiValue Basic Reference
[Home] [Back] [Next]
InterSystems: The power behind what matters   

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
The following example show how LENS handles missing dynamic array elements:
PRINT LENS(nums);  ! Returns 3ý3ý0ý3
See Also

Send us comments on this page
Copyright © 1997-2019 InterSystems Corporation, Cambridge, MA