Arrays (topic)

Declaring Array Variables Arrays in a Basic Control Engine script are declared using any of the following statements:
  Dim
  Public
  Private
For example:
  Dim a(10) As Integer
  Public LastNames(1 to 5,-2 to 7) As Variant
  Private
Arrays of any data type can be created, including Integer, Long, Single, Double, Boolean, Date, Variant, Object, user-defined structures, and data objects. The lower and upper bounds of each array dimension must be within the following range:
  -32768 <= bound <= 32767
Arrays can have up to 60 dimensions. Arrays can be declared as either fixed or dynamic, as described below.
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, Private , or Public statement by supplying explicit dimensions. The following example declares a fixed array of ten strings:
 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.
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)
Subsequent to their initial declaration, dynamic arrays can be redimensioned any number of times. When redimensioning an array, the old array is first erased unless you use the Preserve keyword, as shown below:
 Redim Preserve Ages$(100)
Dynamic arrays cannot be members of user-defined data types.
Passing Arrays Arrays are always passed by reference.
Querying Arrays The following table describes the functions used to retrieve information about arrays.
Use this function to
LBound Retrieve the lower bound of an array. A runtime error is generated if the array has no dimensions.
UBound Retrieve the upper bound of an array. A runtime error is generated if the array has no dimensions.
ArrayDims Retrieve the number of dimensions of an array. This function returns 0 if the array has no dimensions

Operations on Arrays

The following table describes the function that operate on arrays:

Use this command to
ArraySort Sort an array of integers, longs, singles, doubles, currency, Booleans, dates, or variants.
FileList Fill an array with a list of files in a given directory.
DiskDrives Fill an array with a list of valid drive letters.
AppList Fill an array with a list of running applications.
SelectBox Display the contents of an array in a list box.
PopupMenu Display the contents of an array in a pop-up menu.
ReadIniSection Fill an array with the item names from a section in an ini file.
FileDirs Fill an array with a list of subdirectories.
Erase Erase all the elements of an array.
ReDim Establish the bounds and dimensions of an array.
Dim Declare an array.