This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v20.6
New object
|
New object {( property ; value {; property2 ; value2 ; ... ; propertyN ; valueN} )} -> Function result | ||||||||
Parameter | Type | Description | ||||||
property | Text |
![]() |
Name of property to create | |||||
value | Mixed |
![]() |
Value of property | |||||
Function result | Object |
![]() |
New language object | |||||
The New object command creates a new empty or prefilled object and returns its reference.
If you do not pass any parameters, New object creates an empty object and returns its reference. You must assign this reference to a 4D variable declared with C_OBJECT or a 4D object field.
Note: C_OBJECT declares a variable of the Object type but does not create any object.
Optionnally, you can prefill the new object by passing one or several property/value pairs as parameters:
Note that:
This command can create empty of filled objects:
C_OBJECT($obj1)
C_OBJECT($obj2)
C_OBJECT($obj3)
$obj1:=New object
// $obj1 = {}
$obj2:=New object("name";"Smith")
// $obj2 = {name:Smith}
$obj3:=New object("name";"Smith";"age";40)
// $obj3 = {name:Smith,age:40}
Creating a new object with an object as parameter value:
C_OBJECT($Children;$Contact)
//Creating an object array
ARRAY TEXT($arrChildren;3)
$arrChildren{1}:="Richard"
$arrChildren{2}:="Susan"
$arrChildren{3}:="James"
OB SET ARRAY($Children;"Children";$arrChildren)
//Initializing the object
$Contact:=New object("FirstName";"Alan";"LastName";"Parker";"age";30;"Children";$Children)
// $Contact = {FirstName:Alan,LastName:Parker,age:30,Children:{Children:[Richard,Susan,James]}}
This command is useful to pass objects as parameters:
C_OBJECT($measures)
$measures:=Get database measures(New object("path";"DB.cacheReadBytes";"withHistory";True;"historyLength";120))
With this command, you can easily handle objects in loops:
ARRAY OBJECT($refs;0)
C_LONGINT(vCounter)
For(vCounter;1;100)
APPEND TO ARRAY($refs;New object("line";"Line number "+String(vCounter)))
End for
Product: 4D
Theme: Objects (Language)
Number:
1471
Created: 4D v16 R3
4D Language Reference ( 4D v20)
4D Language Reference ( 4D v20.1)
4D Language Reference ( 4D v20.2)
4D Language Reference ( 4D v20.3)
4D Language Reference ( 4D v20.4)
4D Language Reference ( 4D v20.5)
4D Language Reference ( 4D v20.6)