User Guide : Using Content Extraction Language : Arrays : One-Dimensional Arrays
 
Share this page                  
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"
Note that even though CXL arrays are associative, that does not restrict the user from using numbers as subscripts.