4MELFA-BASIC IV
Detailed explanation of command words
4-192
Dim (Dim)
[Function]
Declares the quantity of elements in the array variable. (Arrays up to the third dimension are possible.)
[Format]
[Terminology]
<Variable name>
Describe the name of the array variable.
<Eelement Value>
Describe in terms of constants, the number of elements in an array variable.
[Reference Program]
1 Dim PDATA(10)
' Define the position array variable PDATA having ten elements.
2 Dim MDATA#(5)
' Define double-precision type array variable MDATA# having the five
elements.
3 Dim M1%(6)
' Define integer-type array variable M1% having the six elements.
4 Dim M2!(4)
' Define single-precision real number type array variable M2! having the
four elements.
5 Dim CMOJI(7)
' Define the character-string type variable CMOJI having the seven ele-
ments.
6 Dim MD6(2,3), PD1(5,5)
' Define the 2-dimensional single precision real number type array vari-
able MDATA having the element of 2x3.
' Define the 2-dimensional position array variable PD 1 having the ele-
ment of 5x5.
[Explanation]
(1) A one-dimensional, two-dimensional or three-dimensional array can be used.
(2) In the case of numeric variables, it is possible to use integer, single-precision real and double-precision
real variables differently by adding a symbol that indicates the type of each variable to the variable
name. If the variable type is omitted, a single-precision real variable will be assumed.
Dim MABC(10) ' Define the single-precision real number type array variable MABC having ten ele-
ments.
(3) Eelement number start from 1 when actually referencing array variables. For PDATA on step 10 of the
statement example, the element number will be 1 to 10.
(4) <Eelement Value> can be described with numeric constants from 1 to 999. It is not allowed to use a
numerical value operation expression.
If the number of elements is specified using a real number, an integer with rounded decimal part will be
assumed. Depending on the system memory's free space, arrays may not be allocated for the number
of specified elements. In this case, an error will occur when lines are registered.
(5) If an element number larger than the number of defined elements is specified, an error will occur at the
time of execution.
(6) At the point when array variables are defined, variable values are indeterminate.
(7) To use array variables, it is necessary to define them using the Dim instruction.
(8) The arrays defined by the Dim instruction are valid only in the program where they are defined. To use
these arrays by a sub program called by the CallP instruction, it is necessary to define them again.
(9) Array variables can be used similar to normal variables. However, note that variables of which variable
names and/or the number of characters for specifying element numbers exceed eight characters can-
not be used on the monitor variable screen and position edit screen of the teaching pendant.
(10) If a variable name whose second character is underlined "_" is registered in a user program, a user
defined external variable (a variable common among programs) will be assumed..
Refer to
Page 138, "4.3.24 User-defined external variables"
for details.
Dim[]<Variable name> (<Eelement Value> [, <Eelement Value> [, <Eelement Value>]])
[, <Variable name> (<Eelement Value> [, <Eelement Value>[, <Eelement Value>]])]...