Was this helpful?
One-Dimensional Arrays
CXL provides one-dimensional arrays for storing strings and numbers. All CXL arrays are associative, i.e., indexed by string values. Arrays and array elements do not have to be declared. All arrays are dynamic. They are created as you use them. The number of elements in an array does not have to be specified. Arrays are subscripted with an expression between square brackets [ and ].
Arrays are initialized with the syntax:
arrayname[index expression] = value;
Array values are referenced with the syntax:
variable = arrayname[index expression];
Example 1
cototal[3] = 25; #
creates the cototal array and initializes a value of 25
# in the first element, with an index of "3"
Example 2
cost[armchair] = "$65.00" # creates the cost array and initializes a value of "$65.00"
# in the first element, with an index of "armchair"
Even though CXL arrays are associative, that does not restrict the user from using numbers as subscripts.
Last modified date: 12/03/2024