DIM allocates arrays within HUNTER.
where array size and element size are numeric expressions.
DIM A (25)
defines an array variable A of 26 elements, including the element A(0). The array size must be positive.
defines multiple arrays. N is a previously defined variable.
There are three kinds of DIM statement in HUNTER Basic: Simple variables, double precision variables and strings.
The maximum number of elements in a single array is 16,384.
All array types have a range from 0 (zero) to the limit defined in the DIM statement.
Arrays can be allocated to any combination of variable names.
Double precision arrays are defined in the same way except for the use of “!”. Each element has a 14-digit size.
DIM A!(25) DIM AZ!(32)
define double precision arrays.
Space for string arrays is reserved in HUNTER memory using a DIM statement followed by string name, the number of elements in the array, and the maximum string length required.
defines a string array with 25 elements each of maximum length of 10 characters.
Each character in a string requires 1 byte of storage.
Since HUNTER retains variable definitions indefinitely, DIM statements should not be included in normal user program sequences. Instead, arrays should be initialised by a separate routine or defined directly i.e. without line numbers.
A useful technique is to set in the application software a switch indicating whether the program is being used for the first time or not. If the switch is a variable which is made non zero when the program is first run, the fact that any modifications or use of the CLEAR statement will clear the value to zero can be used to determine whether the arrays should be redefined or not.
10 If A = 1 THEN GO TO 100 20 DIM J(50) 90 A = 1 100 REM user program starts here.
That the variable A could be used as a counter to indicate the number of times that the program has been run.
Default values for numeric arrays are 10 elements. Strings default to one element of 20 character, larger strings have to be dimensioned.