| |
array
Format:
array (size [, reserve]) |
Purpose:
Creates an object with size fields.
Such an object can be used as an array, using the [] operator
with integer arguments.
The size and reserve parameters must be positive integers.
If the reserve parameter is not given or less than size,
it defaults to size.
The reserve parameter can be used to increase the efficiency if
the array is going to be enlarged.
It determines how much memory should be reserved for the array.
In cases where the array is enlarged using the resize() function,
the reserved space is used if possible.
Return Values:
Returns the created array object.
Example:
input: | // Use the array() function to create a multidimensional array
// and assign values to each element.
<let x=array(3); // Declare the array
i=0; j=0; // Initialize sub-array counters
while j<=2; // Begin outer loop to assign data fields
i=0; x[j]=array(3); // Declare the sub-array
while i<=2; // Begin inner loop to assign data fields
x[j][i]=chr(j+i+65); // Assign data
? "x[";?j;?"][";?i;?"] = "; ? x[j][i]; // Display the data
? "\n"; // Carriage return - line feed
let i=i+1; // Increment inner loop counter
/while // End inner loop
? "\n"; // Skip a line between array groupings
let j=j+1; // Increment outer loop counter
/while; // End outer loop.
> | resulting output:
|
x[0][0] = A
x[0][1] = B
x[0][2] = C
x[1][0] = B
x[1][1] = C
x[1][2] = D
x[2][0] = C
x[2][1] = D
x[2][2] = E
|
Note:
An array such as the one above can be used to display rows and columns of data in a Table. A more complex 3-dimensional array could be declared as x[year][month][sales] for Accounting purposes to track sales by period. And, of course, anyone engaged in the analysis of mathematical or statistical data can declare an n-dimensional matrix to suit their individual needs.
|
See Also:
ArAppend(), ArConcat(), ArSearch(), resize().
This page was dynamically generated by the
web application development tool RADpage
of H.E.I.
H.E.I. provides support, tools, and services like
Webdesign in Mannheimm,
the HTML/CSS 3D WebGL Animation Library taccgl,
3D Webdesign, and
3D Product ConfiguratorDemo
(3D Produkt Konfigurator Demo in German).
© 1996-2025 H.E.I. All Rights Reserved.
|