4D v14.3

ARRAY OBJECT

Home

 
4D v14.3
ARRAY OBJECT

ARRAY OBJECT 


 

ARRAY OBJECT ( arrayName ; size {; size2} ) 
Parameter Type   Description
arrayName  Array in Name of array
size  Longint in Number of array elements or Number of arrays if size2 is specified
size2  Longint in Number of 2D array elements

The ARRAY OBJECT command creates and/or resizes an array of language Object type elements in memory.

The arrayName parameter is the name of the array. You can use any name that conforms to 4D conventions.

The size parameter is the number of array elements.

The size2 parameter is optional. If you pass it, this command creates a two-dimensional array. In this case, size specifies the number of rows and size2 the number of columns in each array. Each row in a two-dimensional array can be processed both as an element and an array. This means that when you work with the first dimension of a two-dimensional array, you can insert and remove entire arrays using other commands in the "Arrays" theme. 

When you apply the ARRAY OBJECT command to an existing array:

  • If you enlarge its size, existing elements are not changed and new elements are undefined. You can test whether an element is defined using the OB Is defined command.
  • If you reduce its size, elements at the "bottom" of the array are deleted and lost.

Creation of a process array of 100 Object-type elements:

 ARRAY OBJECT(arrObjects;100)

Creation of a local array of 100 rows each containing 50 Object-type elements:

 ARRAY OBJECT($arrObjects;100;50)

Creation and filling of a local object array:

 C_OBJECT($Children;$ref_richard;$ref_susan;$ref_james)
 ARRAY OBJECT($arrayChildren;0)
 OB SET($ref_richard;"name";"Richard";"age";7)
 APPEND TO ARRAY($arrayChildren;$ref_richard)
 OB SET($ref_susan;"name";"Susan";"age";4)
 APPEND TO ARRAY($arrayChildren;$ref_susan)
 OB SET($ref_james;"name";"James";"age";3)
 APPEND TO ARRAY($arrayChildren;$ref_james)
  // $arrayChildren{1} -> {"name":"Richard","age":7}
  // $arrayChildren{2} -> {"name":"Susan","age":4}
  // $arrayChildren{3} -> {"name":"James","age":3}

 
PROPERTIES 

Product: 4D
Theme: Arrays
Number: 1221

 
HISTORY 

New
Created: 4D v14

 
SEE ALSO 

C_OBJECT
Creating Arrays
Objects (Language)

 
ARTICLE USAGE

4D Language Reference ( 4D v14 R3)
4D Language Reference ( 4D v14 R2)
4D Language Reference ( 4D v14.3)
4D Language Reference ( 4D v14 R4)