Hitachi

JP1 Version 11 JP1/Script Description and Reference (For Windows Systems)


8.2.2 Dim (array) (declare an array variable and allocate space)

Purpose

Declares an array variable and allocates space in memory.

Syntax
Dim VarName ([Number1] [, Number2]) [, VarName ([Number1] [, Number2]), ...]
Dim VarName [ [Number1] [, Number2] ] [, VarName [ [Number1] [, Number2] ], ...]
Arguments
VarName

Specify the variable name of the array variable you are defining. Comply with the variable naming conventions.

Number1

Specify the number of elements in the array variable (or the number of rows for a two-dimensional array). Write a number or a variable that stores this value.

If you omit this argument, the array variable will have a variable number of elements.

Number2

For a two-dimensional array variable, specify the number of columns or a variable that stores this value.

If you omit this argument, the array variable will have a variable number of elements.

Description

An array variable declared at the script level using the Dim (array) command can be referenced within that script by all procedures. An array variable declared at the procedure level can be referenced only within that procedure.

Note that an array variable declared in a Do...Loop, For...Next, For...End For, or While...End loop at the script level or procedure level can be referenced only within that loop.

When a fixed array variable is declared, the Empty value is set for all the elements of the array variable.

Examples
' Declare table1 as a fixed two-dimensional array
' variable.
Dim table1(5,6)
 
' Assign all the elements of the fixed one-dimensional
' array variable table2 to the dynamic one-dimensional
' array variable table3.
Dim table2(6), table3()
For i = 1 To 6
  table2(i) = Time()
Next
table3 = table2
 
' Compare the fixed one-dimensional array variable table4
' with array variable table5.
Dim table4(6), table5(6)
  ...
If table4 = table5 Then
  ...
' The following size comparison is not allowed and results
' in an error.
If table4 <= table5 Then
  ...
JP1/Script version

Supported from JP1/Script 06-00.