User`s guide
E-Prime User’s Guide
Chapter 4: Using E-Basic
Page 158
Dim position_array ( ) As Integer
Fixed arrays
The dimensions of fixed arrays cannot be adjusted at execution time. Once declared, a fixed
array will always require the same amount of storage. Fixed arrays can be declared with the Dim
statement by supplying explicit dimensions. The following example declares a fixed array of
eleven strings (assuming the option base is 0, see Using an Array Index below):
Dim a(10) As String
Fixed arrays can be used as members of user-defined data types. The following example shows
a structure containing fixed-length arrays:
Type Foo
Rect(4) As Integer
Colors(10) As Integer
End Type
Only fixed arrays can appear within structures. Refer to section 4.7.3 for a discussion of user-
defined types.
Dynamic arrays
Dynamic arrays are declared without explicit dimensions, as shown below:
Public Ages() As Integer
Dynamic arrays can be resized at execution time using the ReDim statement:
ReDim Ages (100)
ReDim modifies the dimensions of an array, specifying a new upper and lower bound for each
dimension. After they are declared, dynamic arrays can be redimensioned any number of times.
When redimensioning an array, the old array is first erased unless the Preserve keyword is used,
as shown below:
ReDim Preserve Ages (100)
Dynamic arrays cannot be members of user-defined data types.
4.7.1.2 Using an Array Index
Unless otherwise specified, items within an array are indexed beginning with zero (i.e., arrays are
zero-based). In other words, the first element within an array is located within index number 0.
For instance, if an array is designed to hold 10 elements, the array should be dimensioned as in
the following:
Dim arrResponses (9) As String
In the previous statement, the arrResponses array is dimensioned to hold 10 elements. Because
array indices begin at 0, the "9" in the dimension statement indicates the largest legal index within
the array, and the total number of elements that the array may contain is one greater than this
number.