In ugBASIC, arrays are accessed using the parenthesis operator ((
and )
) next to the name
of the variable that contains the array. The indices must be inserted inside the brackets to
access the individual elements of the array.
There is no limit to the number of dimensions:
however, the cardinality of indices must be the same as the one used when defining the
array itself. There is, also, a limit related to memory availability. Furthermore,
access to locations is not controlled and therefore particular care must be taken not to exceed
the boundaries of the area intended to hold the information on the array.
When an array is accessed, it can be done in two ways: to retrieve a value (read access)
or to set a value (write access). Read access occurs any time the array is used in an
expression. Conversely, for write access, the indexed array must be used as the target variable.
In accessing the array, as in any other variable, the dollar sign ($
) can be juxtaposed
to indicate that you want to access a variable of type string. In this case, a further
type check will be carried out during the compilation, to avoid referring to a variable
of numerical type.
... = var( o1 [, i2 [, ...] ] ) var( o1 [, i2 [, ...] ] ) = expr ... = var$( o1 [, i2 [, ...] ] ) var$( o1 [, i2 [, ...] ] ) = expr$
readElement = a(42,3) b(1,1) = 42 word = words$(42) words$(1) = "ok!"
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