version 6.0
Each of the array declaration commands can create or resize one-dimensional or two-dimensional arrays. Example:
ARRAY TEXT (atTopics;100;50) ` Creates a text array composed of 100 rows of 50 columns
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:
` Create as many initially empty rows as tables ARRAY POINTER (<>apFields;Count tables;0) ` For each table For ($vlTable;1;Size of array(<>apFields)) ` Resize the row with as many columns as fields in the table INSERT ELEMENT (<>apFields{$vlTable};1;Count fields($vlTable)) ` Set the values of the elements For ($vlField;1;Size of array(<>apFields{$vlTable})) <>apFields{$vlTable}{$vlField}:=Field($vlTable;$vlField) End for 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:
` Get the pointers to the fields for the table currently displayed at the screen: COPY ARRAY (<>apFields{Table(Current form table)};$apTheFieldsIamWorkingOn) ` Initialize Boolean and Date fields 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.
See Also