KRASCHE
&
BYRNE
         ELZED  HOME       NEWS       DOCS       DOWNLOADS       LICENSING       SUPPORT       FAQ       ABOUT  US

What's An Elzed?
Features
Licensing
Downloads
Documentation
Elzed News
    ELZED 
 Documentation 
 The Details 

Arrays

Arrays within Elzed are something of a hybrid, combining C/C++ element ordering, vector concepts, and BASIC syntax. An array is indexed with a single set of brackets '[ ]'; the enclosed index list is punctuated by commas. Array indexes are zero-based, with up to six dimensions supported.

Why, you may ask, does Elzed provide for up to six array dimensions? A reasonable question. Let me say that, in my experience, using more than two array dimensions is not only rare but bloody confusing. One can argue, however, that not everyone has had this experience and might need more dimensions for some application not foreseen by my humble self. Six is unreasonably high without being unwieldy, so six it is. My apologies to Dr. Hawking, who apparently feels that eleven dimensions are just fine, thank-you very much.

An element in a three-dimensional array named "winston" might be addressed like this:

winston[ 1, 0, 3 ]

Arrays can be declared in two ways: through an expression, or through an Elzed call.

To declare winston in an expression, one might say this:

global number winston[ 2, 5, 10 ];

To declare winston via the Elzed API, call lzCreateNumArray, like this:

lzCreateNumArray( 'G', "winston", 3, 2, 5, 10, 0, 0, 0 );

The equivalent C/C++ declaration would be:

double winston[2][5][10];

In all the above examples, winston's first element is [0,0,0]. Its last element is [1,4,9].

Its also possible to link an Elzed array to an array in your code. To link a C++ or VB array named "myArray" to an Elzed array named "winston", make a call to lzLinkNumArray, like this:

lzLinkNumArray( 'G', "winston", myArray, 3, 2, 5, 10, 0, 0, 0 );

String arrays are declared a little differently. In addition to the dimensions, you must also declare the string size. An array of 16 strings, each 128 characters long, might be declared like this:

global string waldorf[ 16, 128 ]

When processing a string declaration, Elzed will interpret the last dimension as the string size. Consider this string declaration:

global string astoria[ 32 ]

This declaration will establish a string variable of 32 characters, rather than a string array. Elzed API calls to create and link string arrays also require a string length (128, in these examples):

lzCreateStrArray( 'G', "waldorf", 128, 1, 16, 0, 0, 0, 0, 0 );
lzLinkStrArray( 'G', "waldorf", myArray, 128, 1, 16, 0, 0, 0, 0, 0 );

Several built-in statistical operators will accept a numeric array as a parameter. Regardless of how the array is declared, these operators will only process elements in the first dimension, thus treating the array as a single-column list of numbers sometimes called a "vector".

Several Elzed API calls also work with arrays. View the API "arrays" category for more info.



  Copyright  ©  MMXXIV  by  R R Le Cropane   •   All Rights Reserved   •   Terms of Use   •   Privacy Policy