4D v16.3Creating Arrays |
||||||||||||||||||||||||||||
|
4D v16.3
Creating Arrays
Creating Arrays
You create an array with one of the array declaration commands described in this chapter. The following table lists the array declaration commands:
Each array declaration command can create or resize one-dimensional or two-dimensional arrays. For more information about two-dimensional arrays, see the Two-dimensional Arrays section. (*) There is no difference between Text and String arrays. The strLen parameter of the _o_ARRAY STRING command is ignored. It is recommended to use Text arrays. The _o_ARRAY STRING command is only kept for compatibility reasons. The following line of code creates (declares) an Integer array of 10 elements: ARRAY INTEGER(aiAnArray;10) Then, the following code resizes that same array to 20 elements: ARRAY INTEGER(aiAnArray;20) Then, the following code resizes that same array to no elements: ARRAY INTEGER(aiAnArray;0) You reference the elements in an array by using curly braces ({…}). A number is used within the braces to address a particular element; this number is called the element number. The following lines put five names into the array called atNames and then display them in alert windows: ARRAY TEXT(atNames;5) Note the syntax atNames{$vlElem}. Rather than specifying a numeric literal such as atNames{3}, you can use a numeric variable to indicate which element of an array you are addressing. Using the iteration provided by a loop structure (For...End for, Repeat...Until or While...End while), compact pieces of code can address all or part of the elements in an array. There are other 4D commands that can create and work with arrays. More particularly:
See also
_o_ARRAY STRING
|
PROPERTIES
Product: 4D
HISTORY
ARTICLE USAGE
4D Language Reference ( 4D v16) |
||||||||||||||||||||||||||