The DIM
command allows you to define a vector or a multidimensional array of values,
and to initialize this array with the preferred values.
The simplest syntax is that which defines a vector of a single dimension: in this case,
it is sufficient to indicate the number of elements in parentheses. With the keyword
AS
you can indicate the data type of each single element. You can, of course,
define a matrix (i.e. a vector with two or more dimensions). In this case it is
sufficient to indicate the number of elements for each dimension, separating them
with a comma.
By definition, the array will be initialized with a value of zero for each element.
You can change this behavior by specifying an initialization by assignment. The
initialization can be done by indicating each single value of each single element,
with the same type of data with which the matrix was created (with the # {...}
syntax ), or by describing the memory area that will occupy the array, byte by byte
(with the # [...]
syntax ).
DIM id [AS type] ( d1 [, d2 [ , ... ] ] ) DIM id [AS type] ( d1 [, d2 [ , ... ] ] ) = #[hex] DIM id [AS type] ( d1 [, d2 [ , ... ] ] ) = #{v1, v2, ... } DIM id [AS type] WITH v ( d1 [, d2 [ , ... ] ] )
Join BASIC 10Liner Contest with ugBASIC!
An interesting competition is held at the beginning of each year: the
BASIC 10Liner Contest.
It is possible to use ugBASIC to participate in the next
"BASIC10Liner" competition, in the following categories:
DIM ↔ Di
If you have found a problem with this keyword, if you think there is a bug or, more
simply, you would like it to be improved, open an issue for this example on GitHub.
Thank you!
open an issue
BACK TO KEYWORDS