Create an object of type array.

An array is a structure, which allows to storing objects in an ordered way.

Array can be traversed sequentially and you can also access a specific index to obtain the object of that position.

1 array

<array name='name'>
    <value /> *
</array>

Remarks

The indexing range of all variables type array always start with the position 0.

Example

Declare and initialize an array using variables type string.

Copy
<xsql-script name='array_test1'>
    <body>
        <array name='cities'>
            <string>Barcelona</string>
            <string>Paris</string>
            <string>Roma</string>
        </array>

        <println><cities/></println>
    </body>
</xsql-script>

A variable named 'cities' is declared and it is initialized with three elements of string type: 'Barcelona', 'Paris' and 'Roma'.

The result is:

Copy
Barcelona
Paris
Roma
Example

Declare and initialize an array using variables type string.

Copy
<xsql-script name='array_test2'>
   <body>
       <set name='colour1'>yellow</set>
       <set name='colour2'>red</set>
       <set name='colour3'>blue</set>

       <array name='colours'><colour1/><colour2/><colour3/></array>

       <println><colours/></println>
   </body>

</xsql-script>

A variable named ‘colours’ is declared and it is initialized with the content of the variables: colour1, colour2 and colour3 (yellow, red and blue, respectively).

The result is:

Copy
yellow
red
blue