Len

Returns the length of an expression or data type

Syntax
	KeyPgDeclareDeclare KeyPgFunctionFunction Len ( KeyPgByrefByRef expression KeyPgAsAs KeyPgStringString ) KeyPgAsAs KeyPgIntegerInteger
	KeyPgDeclareDeclare KeyPgFunctionFunction Len ( KeyPgByrefByRef expression KeyPgAsAs KeyPgZstringZString ) KeyPgAsAs KeyPgIntegerInteger
	KeyPgDeclareDeclare KeyPgFunctionFunction Len ( KeyPgByrefByRef expression KeyPgAsAs KeyPgWstringWString ) KeyPgAsAs KeyPgIntegerInteger

	KeyPgDeclareDeclare KeyPgOperatorOperator Len ( KeyPgByrefByRef expression KeyPgAsAs DataTypedatatype ) KeyPgAsAs DataTypedatatype

	KeyPgDeclareDeclare KeyPgFunctionFunction Len ( datatype ) KeyPgAsAs KeyPgIntegerInteger	

Usage
	result = Len( expression )
		or
	result = Len( DataTypeDataType )

Parameters
	expression
		An expression of any type.
	datatype
		A DataTypeDataType.

Return Value
	Returns the size of an expression or DataTypeDataType (including the data fields 
	of a UDT) in bytes.

Description
	Len returns the length of an expression or the size of a DataTypeDataType, in 
	bytes.

	In the first form, if expression is of type KeyPgStringString, KeyPgWstringWString or KeyPgZstringZString, 
	the length of the string in characters will be returned. If the 
	expression is of a user defined type, an KeyPgOperatorOperator Len compatible with 
	that data type is called.  Otherwise, the size of the expression's data 
	type in bytes is returned.

	In the second form, if expression is KeyPgZstringZString or KeyPgWstringWString, the size in 
	bytes of an ASCII or Unicode character is returned, respectively. If 
	datatype is KeyPgStringString, the size of the string descriptor type is returned.

	If there is both a user defined type and a variable visible with the 
	same name in the current scope, the user defined type takes precedence 
	over the variable.  To ensure that the Len takes the variable instead of 
	the user defined type, wrap the argument to Len with parentheses to 
	force it to be seen as an expression.  For example Len((variable)).

	Note: When used with array names, Len returns the length of the array 
	datatype, but not the total number of its elements.
	For clarity, it is recommended that you avoid this potential confusion, 
	and use Len on the array datatype doing Len(Typeof(array)), rather than 
	the array name only doing Len(array).

	The Len unary KeyPgOperatorOperator can be overloaded with user defined types.

Example
	Print Len("hello world") 'returns "11"
	Print Len(Integer) ' returns 4

	Type xyz
	   a As Integer
	   b As Integer
	End Type

	Print Len(xyz) ' returns 8
	   

Version
	* Before fbc 1.08.0:
			Len was not returning the size of the data fields of a UDT.
			When a variable from a given namespace was accessed with the 
			namespace's name prefix, the argument to Len had to be wrapped 
			with parentheses to force it to be seen as an expression. For 
			example Len((namespace_name.variable)).

Dialect Differences
	* Len only allows expressions in the CompilerOptlang-lang qb dialect. 
	* Can be used with built-in types and user-defined types in the CompilerOptlang-lang fb
	  and CompilerOptlang-lang fblite dialects.

Differences from QB
	* Can be used with built-in types and user-defined types in the CompilerOptlang-lang fb
	  and CompilerOptlang-lang fblite dialects.
	* None in the CompilerOptlang-lang qb dialect.

See also
	* KeyPgSizeofSizeOf

