{{htmlmetatags>metatag-robots=()
metatag-title=(DIM | ugBASIC User Manual)
metatag-keywords=(ugBASIC,Commodore 64,Commodore PLUS/4,ZX Spectrum)
metatag-description=(Manual page for DIM)
metatag-media-og:image=(:ugbasic:logo-ugbasic-fb.png)
metatag-og:title=(DIM | ugBASIC User Manual)
metatag-og:description=(Manual page for DIM)
}}
====== ugBASIC User Manual ======
===== DIM ✓ =====
===== SYNTAX =====
DIM variable [AS datatype] [, variable [AS datatype] [ , variable [AS datatype] ] ]
DIM variable [AS datatype] = constant
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 [ , ... ] ] )
==== PURPOSE ====
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 ).
==== EXAMPLE ====
DIM x(42)
DIM values AS DWORD(20,20)
DIM y AS BYTE(8) = #[ff80ff80ff80ff80]
DIM z AS BYTE(8) = _
#{ 255, 128, 255, 128, 255, 128, 255, 128 }
DIM scores WITH 0 (2)
See also the following example files:
* ''[[https://github.com/spotlessmind1975/ugbasic/tree/main/examples/arrays_examples_01.bas|arrays_examples_01.bas]]''
* ''[[https://github.com/spotlessmind1975/ugbasic/tree/main/examples/arrays_examples_02.bas|arrays_examples_02.bas]]''
* ''[[https://github.com/spotlessmind1975/ugbasic/tree/main/examples/arrays_examples_03.bas|arrays_examples_03.bas]]''
* ''[[https://github.com/spotlessmind1975/ugbasic/tree/main/examples/arrays_examples_04.bas|arrays_examples_04.bas]]''
* ''[[https://github.com/spotlessmind1975/ugbasic/tree/main/examples/arrays_examples_05.bas|arrays_examples_05.bas]]''
* ''[[https://github.com/spotlessmind1975/ugbasic/tree/main/examples/contrib_sierpinski.bas|contrib_sierpinski.bas]]''
* ''[[https://github.com/spotlessmind1975/ugbasic/tree/main/examples/contrib_sierpinski2.bas|contrib_sierpinski2.bas]]''
* ''[[https://github.com/spotlessmind1975/ugbasic/tree/main/examples/contrib_sierpinski3.bas|contrib_sierpinski3.bas]]''
==== ABBREVIATION ====
Di
==== AVAILABLE ON ====
*
* Atari (400/800)
* Atari XL/XE
* Commodore 128 (MOS 8502)
* Commodore 128 (Zilog Z80)
* Commodore 64
* Commodore 64+REU
* TRS-80 Color Computer
* TRS-80 Color Computer 3
* ColecoVision
* Amstrad CPC 664
* Dragon 32
* Dragon 64
* Thomson MO5
* Thomson MO5
* Olivetti Prodest PC128
* Commodore PLUS/4
* SEGA SC-3000
* SEGA SG-1000
*
* VG-5000
* Commodore VIC-20
* ZX Spectrum 48
==== SEE ALSO ====
[[VAR]]
==== ANY PROBLEM? ====
If you have encountered a problem using this command, if you think there is a bug or the explanation is unclear, please [[https://github.com/spotlessmind1975/ugbasic/issues/new?title=ISSUE ON DIM|open an issue]] for this keyword on GitHub. Thank you!===== POWERED BY =====
[[:ugbasic:user:index|{{ :ugbasic:user:logo-ugbasic.png?nolink&600 |}}]]