Storage requirements and restrictions

You can determine the amount of storage required for a variable of a User-Defined Type using the LEN function.  To determine the requirements for a student record, for example, use:

RecordSize = LEN(Student)

The address of a record variable, as returned by the VARPTR function, is the address in memory of the first byte of data in the record.  You can also obtain the starting address of the fields within the record by passing the full name of the field (Student.IdNum, for example) to the VARPTR function.

A single UDT structure is limited to 16 Mb (16,777,216 bytes).  Locally dimensioned UDT structures are limited to the amount of free stack space available, typically less than 1 Mb.  If larger UDT structures are required, use a STATIC or GLOBAL declaration instead (since these are not stored on the stack).  The same rules apply to Unions (and LOCAL fixed-length and ASCIIZ strings).

Note that the ARRAY statements cannot be directly used on arrays within UDTs.  However, you can use DIM..AT to define an array (of the same data type) at the address of the UDT array, and employ ARRAY statements on that array.  The ARRAY statements can be used on arrays of UDT structures.  An individual array within a UDT may occupy as much as the full 16 Mb UDT size limit.

 

See Also

User-Defined Types (UDTs)

Unions