Arrays within User-Defined Types

In prior versions of this compiler, arrays could not be part of a UDT structure.  However, we now support both one and two-dimensional arrays of variables that have a fixed-length (for each element) - this includes nul-terminated strings, fixed-length strings, and all numeric variable classes.  Individual arrays within a UDT may be up to 16 Megabytes each (although UDTs themselves are limited to 16 Megabytes).

Two-dimensional arrays within Types work exactly as do any other array in PowerBASIC, except that their dimensions are specified by positive numeric constant values, and are therefore not dynamically alterable.  That is, the dimension sizes must be specified with numeric equates or numeric literal values, and these cannot be altered at run-time.

Like conventional arrays, the default lower array boundary is zero, but positive non-zero values may be used to specify a specific range of subscript index values for the array, separated from the upper array boundary subscript with the TO keyword.  Additionally, both the lower and upper subscript index values must be zero or greater (ie, negative subscript values are not permitted).  Examples of valid syntax follow:


  id AS INTEGER              ' Scalar UDT member

  Styles(6)         AS DWORD '  7 elements (0 TO 6)

  Yrs(1980 TO 2010) AS LONG  ' 31 elements

  Team(100 TO 101)  AS BYTE  '  2 elements

  Rating(1 TO 10)   AS DWORD ' 10 elements

  X(1 TO 5, 0 TO 5) AS EXT   ' 30 elements (5x6)

  Y(4,3)            AS QUAD  ' 20 elements (5x4)



See Also

Array Data Types


String arrays

Multidimensional arrays

Array storage requirements

Internal representations of arrays

Array operations