Each of the array declaration commands can create or resize one-dimensional or two-dimensional arrays. Example:
ARRAY TEXT(atTopics;100;50)
Two-dimensional arrays are essentially language objects; you can neither display nor print them.
In the previous example:
- atTopics is a two-dimensional array
- atTopics{8}{5} is the 5th element (5th column...) of the 8th row
- atTopics{20} is the 20th row and is itself a one-dimensional array
- Size of array(atTopics) returns 100, which is the number of rows
- Size of array(atTopics{17}) returns 50, which the number of columns for the 17th row
In the following example, a pointer to each field of each table in the database is stored in a two-dimensional array:
C_LONGINT($vlLastTable;$vlLastField)
C_LONGINT($vlFieldNumber)
$vlLastTable:=Get last table number
ARRAY POINTER(<>apFields;$vlLastTable;0)
For($vlTable;1;$vlLastTable)
If(Is table number valid($vlTable))
$vlLastField:=Get last field number($vlTable)
$vlColumnNumber:=0
For($vlField;1;$vlLastField)
If(Is field number valid($vlTable;$vlField))
$vlColumnNumber:=$vlColumnNumber+1
INSERT IN ARRAY(<>apFields{$vlTable};$vlColumnNumber;1)
<>apFields{$vlTable}{$vlColumnNumber}:=Field($vlTable;$vlField)
End if
End for
End if
End for
Provided that this two-dimensional array has been initialized, you can obtain the pointers to the fields for a particular table in the following way:
COPY ARRAY(◊apFields{Table(Current form table)};$apTheFieldsIamWorkingOn)
For($vlElem;1;Size of array($apTheFieldsIamWorkingOn))
Case of
:(Type($apTheFieldsIamWorkingOn{$vlElem}->)=Is date)
$apTheFieldsIamWorkingOn{$vlElem}->:=Current date
:(Type($apTheFieldsIamWorkingOn{$vlElem}->)=Is Boolean)
$apTheFieldsIamWorkingOn{$vlElem}->:=True
End case
End for
Note: As this example suggests, rows of a two-dimensional arrays can be the same size or different sizes.