Array Functions in DIAL
The array functions in DIAL create and manipulate arrays. Arrays are dynamic, ordered lists of values. Each element in an array is a value, which might be another array.
Adds the specified value to the end of the array, which increases the size of the array by one.
Returns the number of elements in the array.
Removes the element at the specified index from the array, which decreases the array size by one. The first element of the array is at index 1.
Returns the element at the specified index from the array. The first element of the array is at index 1.
Inserts the specified value into the array immediately before the element at the specified index, which increases the array size by one. The first element of the array is at index 1. Therefore, array.insert(a, 1, elem) inserts elem at the beginning of the array. If the index is greater than the size of the array, null values are added to the array until it is large enough to place the value in the specified index.
Creates a new empty array.
Creates a new array with the specified number of elements. All the elements in the resulting array are null.
Replaces the element at the specified index in the array with the specified value. The size of the array remains the same. The first element of the array is at index 1.
Array Function Example
The following example creates an array with three elements. It then loops through the array to write out the elements. The array is composed of three divisions of a company: Alpha Brands, Delta Brands, and Omega Brands.
a = array.new(); array.add(a,"Alpha Brands"); array.add(a,"Delta Brands"); array.add(a,"Omega Brands"); i = 1; end = array.count(a)+1; while (i != end) { value = array.get(a,i); console.writeln(value); i=i+1; } console.writeln("Done!");