# DIMENSION (DIM)

Updated: 11/30/2021, 7:00:45 PM
Created: 11/30/2021, 7:00:45 PM
Last Updated By: Jake Tuttle
Read Time: 1 minute(s)

Tags: dimensioned array

# Description

The DIM statement is used to declare arrays to the compiler before referencing.

DIM{ENSION} variable(number{, number, ... }){, variable(number {,number, ...}) ...}
1

Where:

  • variable may be any valid variable name neither declared nor previously used.
  • numbers defines the size of each dimension and must be either constants or the subject of an EQUATE statement.

A single DIM statement may declare a number of arrays by separating their declarations with a comma.

# Note

  • The array must be declared before it is referenced in the program source (compilation as opposed to execution). If using a variable as an undeclared dimensioned array the compiler will display an error message.
  • The array variable must be used as a normal variable or dynamic array before dimensioning, as the compiler will detect this as an error.
  • Dimensioning to a variable requires resize_array = true to be set as a configuration option in the $JBCRELEASEDIR/config/Config_EMULATE file.
  • When arrays are referenced directly as in A = Array(7), the compiler will optimize the reference as if it was a single undimensioned variable.

The statements in the code snippet below show how arrays can be declared.

EQUATE DimSize1 TO 29
DIM Array1(10,10), Array2(5, 20, 5, 8)
DIM Age(DimSize1)
1
2
3

See also: COMMON

Go back to jBASE BASIC

Go back to Programmers' Reference Guide