
6. The SPEL+ Language
6.7.6 Arrays
You can declare local, module, and global arrays with up to three dimensions for all data
types.
To declare an array, use this syntax:
dataType name ( ubound1 [ , ubound2 [ , ubound3] ] )
SPEL
+
arrays are zero based. The first element is referenced with a value of zero.
The total available number of array elements for local and global preserve variables is 100
for strings and 1000 for all other types.
The total available number of array elements for global and module variables is 1000 for
strings and 10000 for all other types.
To calculate the total elements used in an array, use the following formula. (If a dimension
is not used, substitute 0 for the ubound value.)
total elements = (ubound1 + 1) * (ubound2 + 1) * (ubound3 + 1)
Array declaration examples:
' Global string array
Global String gData$(10)
Function main
' Arrays local to this function
Integer intArray(10)
Real coords(20, 10)
Use Redim to change the bounds of an array at run time.
Integer a(10)
Redim a(20)
To preserve values when using Redim, add the Preserve optional argument.
Integer a(10)
Redim Preserve a(20)
Use UBound to get the upper bound of an array dimension.
Integer i, a(10)
For i = 1 to UBound(a)
a(i) = i
Next i
6.7.7 Initial values
All variables are initialized when first used except for Global Preserve variables. Strings
are set to empty, and all other variables are set to zero.
6.7.8 Clearing arrays
Use Redim (without Preserve) to clear all of the elements of an array at run time.
156 EPSON RC+ 5.0 (Ver.5.4) User's Guide Rev.4
Comentários a estes Manuais