{{fbdoc item="title" value="LEN"}}----
Returns the length of an expression or data type

{{fbdoc item="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]]	
##
{{fbdoc item="usage"}}##
	//result// = **Len**( //expression// )
		##//or//##
	//result// = **Len**( [[DataType|DataType]] )
##
{{fbdoc item="param"}}
	##//expression//##
		An expression of any type.
	##//datatype//##
		A [[DataType|DataType]].

{{fbdoc item="ret"}}
	Returns the size of an expression or [[DataType|DataType]] (and the data fields of a UDT for fbc version >= 1.08) in bytes.

{{fbdoc item="desc"}}
	##**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.
	
	For fbc version < 1.08: When a variable from a given namespace is accessed with the namespace's name prefix, wrap the argument to ##**Len**## with parentheses to force it to be seen as an expression. For example ##Len((namespace_name.variable))##.
	
	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))##.
	
	The ##**Len**## unary ##[[KeyPgOperator|operator]]## can be overloaded with user defined types.

{{fbdoc item="ex"}}
{{fbdoc item="filename" value="examples/manual/strings/len.bas"}}%%(freebasic)
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
%%

{{fbdoc item="lang"}}
	- ##**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.

{{fbdoc item="diff"}}
	- 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.

{{fbdoc item="see"}}
	- ##[[KeyPgSizeof|Sizeof]]##

{{fbdoc item="back" value="CatPgString|String Functions"}}