To meet your needs, we constantly work to improve Querix products.
This means that Lycia documentation is developing as well.
In case you have found a certain dissonance between the provided information and the actual behavior of Lycia 3 and/or your applications, please, let us know about this via documentation@querix.com so that we can introduce the necessary changes to our documentation.
Thank you for your attention and cooperation.
ARRAY is a structured data type that stores a one-, two-, or three-dimensional array of variables of identical data types. The size of each dimension is a positive integer of up to 32,767. Dimensions can be of different size and they can contain variables of any data type, provided that all the elements of the array are of the same data type.
Element |
Description |
Size |
The upper bounds for up to 3 dimensions. Can include from 1 to 3 4GL expressions separated by commas that return positive integers |
4GL Data Type |
Any Querix 4GL or user-defined data type |
A variable included into an ARRAY is called an element. The example below declares a three-dimensional program array called my_array:
DEFINE my_array ARRAY[a,b,c] OF INTEGER
a indicates a-th element of a single-dimensional array. E.g. my_array[3] represents a variable on the third row of the array.
b indicates b-th element in the a-th row within an array that contains two dimensions. E.g. my_array[3, 5] represents the fifth element in the third row of the array
c indicates the c-th element in the b-th column of the a-th row within an array with three dimensions. E.g. my_array[3, 5, 1] represents the first element in the fifth column of the third row of the array.
In SQL...END SQL statement, the variable that represents an array needs a dollar sign ($) preceding it. However no dollar sign is required for a variable used as a coordinate in an array.
Here are several examples of an array declaration:
DEFINE array1 ARRAY[100,100,100] OF RECORD rec1 LIKE client.*
DEFINE array4 ARRAY[500] OF RECORD
variable1 LIKE client.fname,
variable2 INT
END RECORD
DEFINE array2 ARRAY[7,100] OF VARCHAR(20)
DEFINE array3 ARRAY[1000] OF my_rec
In the last example my_rec is a user-defined type of record (created with the help of DEFINE...TYPE AS statement).
You cannot manipulate an array as a single unit; you can only operate its individual elements. A single element can be manipulated by specifying its coordinates next to the name of the array in which it is included. The number of coordinates an element requires depends on how many dimensions there are in the array. A coordinate must be specified for each dimension of a multi-dimensional array. If a coordinate for one or two dimensions is missing, though it is required, 4GL will produce a compile-time error.
You can operate an array as a unity, so it can be passed to and from a function. They are passed by reference.
It is also possible to pass a record that contains an array or a dynamic array as its member as a single unit. However, make sure you avoid cyclic references of such records.
A substring of an array is a list of character values within an individual element of an array of character type (CHAR, STRING or VARCHAR). You can use a pair of integer expressions between square bracket ( [] ) to specify a character substring within the string value of the array element. E.g. If my_array[d, e, f] is an element of a three-dimensional array of character data type, you can specify a substring within this element as follows: my_array[d, e, f] [m, n] where m and n specify the positions of the first and the last character (respectively) of the substring within the array element my_array[d, e, f]. The m and n should be positive integers, m should be smaller than n.