The purpose is to specify how to define variables and arrays, as well as their usage and initialization.
The Ctrl+Sifht-V key combination (or via the Insert/Variable pull-down menu) allows you to define a variable in any editor.
A new variable will be defined when the New Variable button is pressed in the window (opened after Ctrl+Shift-V) and a form displaying all variable characteristics will appear on the screen enabling the desired Variable Definition: type, length, decimal, sign, picture, etc. When this button is pressed a window dialog will be displayed.
Using Multidimensional Arrays
A multidimensional variable array is defined just as a common variable is defined, but you must select the one/two dimension(s) in the Dimensions
property (Scalar, Vector and Matrix) that you will use.
To initialize an array (assign values to its elements) assign an expression to the whole array (indicated by the array’s name followed by parenthesis, without subscripts);. For example:
&arr() = 0
&arr() = nullvalue(&arr)
&arr() = attr + 25/&var
Methods are not supported.
A common use is found when we want to generate a 2D-array report:
&SeatsPerYear() = 0
For Each AirlineId
For Each FlightDepartureTime
Where Year(FlightDepartureTime) >= &Year(1)
Where Year(FlightDepartureTime) <= &Year(3)
For &i = 1 to 3
If Year(FlightDepartureTime) = &Year(&i)
&SeatsPerYear += 1
Array Passed as Parameter
Be sure to define the array in both objects (caller and called), with the same dimension. Otherwise, unpredictable results may occur. Subscripts that are out of range will only be detected at execution time. However, numeric constant subscripts are checked, ensuring that they do not exceed the array’s dimensions.
Array Rows & Columns
The functions Rows(&Arr())
respectively, are used to get the number of rows (1st dimension) and columns (2nd dimension) that have been defined for an array. This is useful, because it is better to work with these functions when defining a programming loop (Do While
), so your loop will never be affected if the dimensions of the array were to change.
The following example illustrates how to load a 2D-array whose elements will be the sum of their subscripts (row and column):
&i = 1
Do while &i <= rows(&arr()) //This cycle will continue to work regardless of changes in the definition of the array.
j = 1
Do while &j <= cols(&arr())
&arr(&i,&j) = &i + &j
&j += 1
&i += 1
This facility is only used by variables and not by attributes (you cannot define attributes as arrays).
You cannot refer to a particular element of the array when using the NoAccept Rule. That is, the array is either entirely accepted or it is not accepted at all. The same applies when assigning colors to an array.
In transactions; arrays cannot be received as parameters.
Objects Procedure object, Transaction object, Web Panel object