| **Navigation:**  [[introduction.htm|Language Reference]] > 5 - Declaration Attributes > Variable and Entity Attributes >====== DIM (set array dimensions) ====== | [[create allow data file creation .htm|{{btn_prev_n.gif|Previous page}}]][[introduction.htm|{{btn_home_n.gif|Return to chapter overview}}]][[dll set variable defined externally in dll .htm|{{btn_next_n.gif|Next page}}]] | | || **DIM(**//dimension,...,dimension//**)** {{blk2blue.jpg|blk2blue.jpg}} | **DIM** | Declares a variable as an array. | | //dimension// | A positive numeric constant which specifies the number of elements in this //dimension// of the array. | The **DIM** attribute declares a variable as an array. The variable is repeated the number of times specified by the //dimension// parameters. Multi-dimensional arrays may be thought of as nested. Each //dimension// in the array has a corresponding subscript. Therefore, referencing a variable in a three dimensional array requires three subscripts. There is no limit to the number of dimensions, and the total size of an array is unlimited. Zero or negative array elements are invalid. Subscripts identify which element of the array is being referenced. A subscript list contains a subscript for each //dimension// of the array. Each subscript is separated by a comma and the entire list is enclosed in brackets ([ ]). A subscript may be a numeric constant, expression, or function. The entire array may be referenced by the label of the array without a subscript list. A GROUP structure array is a special case. Each level of nesting adds subscripts to the GROUP. Data declared within the GROUP is referenced using standard Field Qualification syntax with each subscript specified at the GROUP level at which it is dimensioned. In general, there is a limit to size of data objects declared in global, module or local scope: 4MB. The compiler can report different errors depending from the type of data object exceeding this limit. Particularly, arrays with variable dimensions may be of a slightly greater size than 4MB. {{newcnet.jpg|NewCNet.jpg}} The** CLASS** declaration supports the **DIM** attribute. It provides for creating arrays of objects of any type (for a CLASS declared without the TYPE attribute). **Example:** **Scr   GROUP           !Characters on a DOS text-mode screen** **Row    GROUP,****DIM****(25)  !Twenty-five rows** **Pos     GROUP,****DIM****(80) !Two thousand positions** **Attr     BYTE         !Attribute byte** **Char     BYTE         !Character byte** **        END           !Terminate the group structures** **       END** **      END** ** ! In the group above:** ** !   Scr                 is a 4,000 byte GROUP** ** !   Scr.Row             is a 4,000 byte GROUP** ** !   Scr.Row[1]            is a 160 byte GROUP** ** !   Scr.Row[1].Pos        is a 160 byte GROUP** ** !   Scr.Row[1].Pos[1]       is a 2 byte GROUP** ** !   Scr.Row[1].Pos[1].Attr   is a single BYTE** ** !   Scr.Row[1].Pos[1].Char   is a single BYTE** **Month  STRING(10),DIM(12)  !Dimension the month to 12** ** CODE** ** CLEAR(Month)              !Assign blanks to the entire array** ** Month[1] = 'January'      !Load the months into the array** ** Month[2] = 'February'** ** Month[3] = 'March'** **See Also:** [[maximum return maximum subscript value .htm|MAXIMUM]] [[prototype parameter lists.htm|Prototype Parameter Lists (Passing Arrays)]]