
Declaring Arrays:
DIM symbolname (size )
Declaring Strings:
DIM
symbolname$ (size )
DIM symbolname (size) AS
STRING ' added in 6.24e
Declaring Integers: ' added in 6.24
DIM symbolname AS INTEGER
Declares a named variable and allocates memory to
accommodate it. Though ARMbasic does not require the declaration of
integer variables, DIM is used to assign arrays of integers or strings
(arrays of bytes). The size is the number of elements in the array plus
1. This allows indexing from 0 to size
.
All strings must have the last character the dollar sign $ .
Only one symbolname may be declared with each DIM statement.
Memory for simple variables is allocated from the start of a heap, and
strings or arrays are allocated from the top or end of the heap. Strings
are packed as bytes and always word alligned, you must allow enough space to
accomodate the expected maximum size of the string plus 1 byte for
a termination (0) character. String operators rely on the terminator.
Simple variable
will be automatically declared on first use, unless you use DIM
symbolname AS INTEGER. At which point all subsequent integers
must be declared using a DIM.
SUB procedures also use DIM between SUB .. ENDSUB. Those variables will be local to the procedure. Using DIM here does not change whether all subsequent integers must be declared using a DIM or not. In other words the state whether DIM is required is saved upon entering a SUB procedure and is restored at the ENDSUB.
In version 6.24e, AS STRING syntax was added and the name$ has been relaxed to not require the $.
In version 7.05, AS STRING arrays are no longer limited to 255 bytes, so that they may be used for larger arrays of bytes. However, string operations and functions are limited to 255 bytes.