Home > Language Reference > Compilation > Dim

Dim

The Dim function declare arrays or Unsigned integers at the beginning of a script.

Syntax

Dim tab_integer(<size>)
or
Dim tab_string$(<size>)
or
Dim unsigned_int As Unsigned

Parameter

<size>, integer, constant, . Only one-dimensional arrays are supported. The indexes of the array elements range from 0 through <size>. Maximum size is 65534.

Remarks

Array variables MUST BE DECLARED AT THE VERY BEGINNING OF THE SCRIPT before being used. Functions/Subs declaration must be inserted after arrays declaration. If Included scripts are used, the structure of the full long script with the inclusions must follow the same order, first arrays, second functions/subs, third main program.

See also

Script Structure
Arrays

Examples

dim my_array$(5) 'Declare an array with 6 string elements.
my_array$(0)="test"  'Initialize first element
my_array$(2)="hello"    'Initialize second element
msgbox("First element contains: "+my_array$(0))
msgbox ("Second element contains: "+my_array$(1)) 

dim my_array(100) 'Declare an array with 100 integer elements (first element is my_array(0)).

dim my_pointer as unsigned  'Declare an unsigned integer (a pointer)