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>
Attributes | |||||
---|---|---|---|---|---|
Name | Type | Required | Default | Description | |
Aname | string | Name of the variable of array type. |
Arguments | |||||
---|---|---|---|---|---|
Name | Type | Required | Unique | Nullable | Description |
Evalue | object | Object to add in the array. It may not indicate any object or put several objects, one followed by another, they will be added in an orderly manner in the matrix. |
Returns | |
---|---|
Type | Description |
array | Returns the array of the objects that have been added. |
Remarks
The indexing range of all variables type array always start with the position 0.
Declare and initialize an array using variables type string.
<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:
Barcelona Paris Roma
Declare and initialize an array using variables type string.
<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:
yellow red blue