LEN

Top  Previous  Next

Syntax

size = LEN(variable)

size = LEN(UDT)

Description

Returns the length in bytes of a variable or UDT.

Parameters

variable - Any defined variable.

UDT - The name of a user data type as specified in the TYPE statement

Return value

Depends on the type of variable:

FILE, BFILE - Returns the length of the file, file must have been opened with OPENFILE.

MEMORY - Returns the size of the memory allocated with ALLOCMEM.

UDT - Returns the actual size a UDT takes in memory using the packing value specified in the TYPE statement

STRING - Returns the string length, not the DEF'ined length.

All others - Returns the total size in bytes. For arrays this returns the total size of the array.

Remarks

For a MEMORY variable only memory obtained with ALLOCMEM will return a size.

See Also: ALLOCMEM, DEF, TYPE

Example usage

mystring = "This is a test"
PRINT LEN(mystring)