Using arrays of User-Defined Types

You can create arrays of User-Defined Types just as you can create arrays of Integers or strings or any of PowerBASIC's other data types.  For example:

DIM Class(1 TO 30) AS StudentRecord

To access the individual elements of the Class array, you use subscript index values just as you do with any other array.  The third student record is Class(3), for instance.  The period separator and the field name follows the array subscript:


This would access the first name of the third student in the class array.  Think of it this way: the array is made up of elements of the Type Student Record, so the subscript belongs with the name of the variable as a whole.

You can create multidimensional arrays of User-Defined Types just as you can with any other PowerBASIC data type.  The limit on the number of elements and dimensions in such arrays is governed by the same rules as well: The limits are defined by the amount of data storage required for each element.  Additionally, arrays within structures must contain a static subscript list, defined at compile-time.  Therefore, arrays within structures cannot be redimensioned at run-time.


See Also

User-Defined Types (UDTs)

Defining User-Defined Types

Accessing the fields of a User-Defined Type

Nesting User-Defined Types

Arrays within User-Defined Types

Using User-Defined Types with procedures and functions

Storage requirements and restrictions