Purpose |
Return the logical length of a variable, User-Defined Type, or Union. |
Syntax |
y& = LEN(target) |
Remarks |
If target is a
When used with pointers, LEN returns a value of 4, since a pointer is always stored as a DWORD. You can use LEN with the target of a pointer to return the size of target. If the target is a dynamic string, you will receive the length of the string, not the length of the handle. target
can also be any other variable type, including
When measuring the size of a padded (aligned) UDT structure with the LEN (or SIZEOF) statement, the measured length includes any padding that was added to the structure. For example, the following UDT structure: TYPE LengthTestType DWORD a AS INTEGER END TYPE ' code here DIM abc AS LengthTestType x& = LEN(abc) Returns a length of 4 bytes in x&, since the UDT was padded with 2 additional bytes to enforce DWORD alignment. Note that the LEN of individual UDT members returns the true size of the member without regard to padding or alignment. In the previous example, LEN(abc.a) returns 2. |
See also |
|
Example |
DIM p AS BYTE POINTER ByteLen = LEN(p) ' size of a pointer = 4 bytes ByteLen = LEN(@p) ' size of byte (target) = 1 byte |