LOTUSSCRIPT LANGUAGE
The position of an element in an array can be identified by one or more coordinates called subscripts (or indexes). The number of subscripts necessary to identify an element is equal to the number of the array’s dimensions. In a one-dimensional array, a given element’s position can be described by one subscript; in a two-dimensional array, it takes two subscripts to locate an element.
For example, in a one-dimensional array whose elements are the names of the states of the United States, a single subscript identifies the position of a given state in the collection:
Dim states(1 to 50) As String states(1) = "Alabama" states(2) = "Alaska" states(3) = "Arizona" ' and so on. Print states(2) ' Output: Alaska
In a two-dimensional array whose elements are the names of the ten most populous cities in each state, the first subscript identifies the state, and the second subscript identifies the city:
Dim statesAnd10Cities(1 to 50, 1 to 10) As String statesAnd10Cities(1,1) = "Alabama, Birmingham" statesAnd10Cities(1,2) = "Alabama, Mobile" ' ... statesAnd10Cities(2,1) = "Alaska, Anchorage" statesAnd10Cities(2,2) = "Alaska, Fairbanks" ' and so on. Print statesAnd10Cities(1,2) ' Output: Alabama, Mobile
A three-dimensional array might contain the numbers of adult females, adult males, and children in each of the ten most populous cities in each state:
Dim statesAnd10CitiesAndPeople(1 to 50, 1 to 10, 1 to 3) _ As Double statesAnd10CitiesAndPeople(1,1,1) = 120748 ' Number of adult males in Birmingham, Alabama. statesAnd10CitiesAndPeople(1,1,2) = 145104 ' Number of adult females in Birmingham, Alabama. ' ... statesAnd10CitiesAndPeople(2,1,1) = 116381 ' Number of adult males in Anchorage, Alaska. statesAnd10CitiesAndPeople(2,1,2) = 109957 ' Number of adult females in Anchorage, Alaska. '... Print StatesAnd10CitiesAndPeople(1,1,2) ' Output: 145104
The size of an array — the number of dimensions and the extent of each individual dimension — is defined by the array’s bounds list. Each dimension has a lower bound and an upper bound, specified as integer values.
LotusScript supports both fixed and dynamic arrays.
The syntactic elements in the declaration of an array are summarized as follows:
See Also