This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v20.6
C_OBJECT
|
C_OBJECT ( {method ;} variable {; variable2 ; ... ; variableN} ) | ||||||||
Parameter | Type | Description | ||||||
method | Method |
![]() |
Name of method | |||||
variable | Variable |
![]() |
Name(s) of variable(s) or parameter(s) ${...} to declare | |||||
The C_OBJECT command assigns the Object type to all the variables that are specified.
The Object type is supported by the 4D language starting with v14. Objects of this type are managed by the commands of the Objects (Language) theme or through object notation (see Using object notation).
You use the first syntax of the command (when the method parameter is not passed) to declare and type a process, interprocess or local variable. This syntax can be used in interpreted databases.
You use the second syntax of the command (when the method parameter is passed) to declare the method’s result and/or parameters ($0, $1, $2, etc.) to the compiler in advance. You must use this syntax if you want to skip the variable typing phase in order to save time when the database is compiled.
WARNING: You cannot execute the second syntax in interpreted mode. For this reason, when you use this syntax, you should store it in a method (whose name must begin with "COMPILER") that is not executed in interpreted mode.
Important: The C_OBJECT command does not create an object named variable. If you want to access the properties of the object itself using object notation, you must first initialize it using the New object command, otherwise a syntax error is returned (see example).
The syntax C_OBJECT(${...}) allows you to declare a variable number of parameters of the same type, under the condition that these are the last parameters for the method. For example, the declaration C_OBJECT(${5}) tells 4D and the compiler that starting with the fifth parameter, the method can receive a variable number of parameters of that type. For more information, see the Parameter indirection section.
C_OBJECT($obj) //The $obj variable is declared but the $obj object does not exist
$obj:=New object //The $obj object is initialized
$obj.prop:=42 //...and its properties can be accessed
Product: 4D
Theme: Compiler
Number:
1216
Created: 4D v14
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)