This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v20.6
C_COLLECTION
|
C_COLLECTION ( {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_COLLECTION command assigns the Collection type to all the variables that are specified.
The Collection type is supported by the 4D language starting with v16 R4. Variables of this type contain a sorted list of attribute values of any type, stored as a JSON array.
You use the first syntax of the command (when the method parameter is not passed) to declare and type a local, process, or interprocess 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 have to store it in a method (whose name must begin with "COMPILER") that is not executed in interpreted mode.
The syntax C_COLLECTION(${...}) 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_COLLECTION(${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.
You want to declare a collection process variable and to fill it with a new collection:
C_COLLECTION(myCol)
//here myCol value is null
myCol:=New collection("Green";100;"Orange";200;"Red";300)
//myCol= ["Green",100,"Orange",200,"Red",300]
Product: 4D
Theme: Compiler
Number:
1488
Created: 4D v16 R4
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)