xHarbour Reference Documentation > Function Reference |
Returns the number of items contained in an array, hash or string
Len( <aArray> | <cString> | <hHash> ) --> nCount
The function returns the number of items stored in the passed parameter as a numeric value. When the passed parameter is empty (contains no items), the return value is zero.
The function Len() accepts parameters of three different data types: Array, Character string and Hash. It returns the number of items stored in the passed parameter.
Return value of Len()
Data type | Description |
---|---|
Array | Number of array elements in first dimension |
Character string | Number of characters |
Hash | Number of key/value pairs |
The return value is zero, when an array has no elements, a string has no characters or a hash has no key/value pair.
See also: | Array(), Empty(), Hash(), LenNum(), LTrim(), RTrim() |
Category: | Array functions , Character functions , Hash functions |
Source: | rtl\len.c |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// The example shows return values of Len() with different data types PROCEDURE Main LOCAL aArray := Directory( "*.prg" ) LOCAL cString := "Hello World" LOCAL hHash := { "A" => 1, "B" => 2, "C" => 3, "D" => 4 } ? "Array :" , Len( aArray ) // result: 217 ? "String:" , Len( cString ) // result: 11 ? "Hash :" , Len( hHash ) // result: 4 RETURN
http://www.xHarbour.com