<arr>

Purpose The <arr> statement is used to define an array within the main part of a Superx++ program or within a method. It is not the same as the <arr> clause. There is a syntactical difference in the format of the two: the <arr> statement uses no curly braces around its initial element values whereas the <arr> clause does. Also, the purposes of the two are different. The <arr> clause defines a member array of a class, whereas the <arr> statement defines an array which is stand-alone.
Format <arr type="{datatype}" name="{name and size}">
   {comma-separated elements}
<arr>

{datatype} the datatype of the array and all its elements
{name and size} the name of the array followed by the number of elements in the array bounded by square brackets
{comma-separated elements} (optional) the initial values of the array elements should be separated by commas

What an Array looks like in Run-Time Memory
An array which is defined with the following statement:
<arr type="int" name="score[5]">
   100,50,75,90,95
</arr>

will look like this in run-time memory (assuming run-time memory was empty beforehand):
<xppRAM arr_int_score.5.="{100,50,75,90,95}" />

where xppRAM is the memory object.


Renderings of an Array with Various Datatypes in Run-Time Memory
Datatype Rendering in Run-Time Memory
bool arr_bool_{array name}.{array size}.="{values}" />
date arr_date_{array name}.{array size}.="{values}" />
double arr_double_{array name}.{array size}.="{values}" />
float arr_float_{array name}.{array size}.="{values}" />
int arr_int_{array name}.{array size}.="{values}" />
long arr_long_{array name}.{array size}.="{values}" />
short arr_short_{array name}.{array size}.="{values}" />
string arr_string_{array name}.{array size}.="{values}" />
{array name} name of the array
{array size} number of elements in the array
{values} comma-separated list of the values of the array bounded by curly braces

Example #1 <arr type="int" name="score[5]">
   100,50,75,90,95
</arr>

Defines an array called score which has 5 elements: the value of the 1st element is 100, the value of the 2nd is 50 and so on.

Example #2 <arr type="int" name="score[5]">
   100,50,75,90,95
</arr>
<xout>The 3rd array element has the value </xout>
<xout>
   <eval object="score[2]" />
</xout>

The same array, score[5], is defined and the string The 3rd array element has the value 75 is sent to the output stream because 75 is returned as the value of score[2].

Example #3 <arr type="int" name="score[5]">
   100,50,75,90,95
</arr>
<eval object="score[2]">99</eval>
<xout>The 3rd array element has the value </xout>
<xout>
   <eval object="score[2]" />
</xout>

The same array, score[5], is defined and the score[2] is set to 99. The string The 3rd array element has the value 99 is sent to the output stream because 99 is returned as the value of score[2].