This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v20.6
C_VARIANT
|
C_VARIANT ( {method ;} variable {; variable2 ; ... ; variableN} ) | ||||||||
Parameter | Type | Description | ||||||
method | Method |
![]() |
Optional name of method | |||||
variable | Variable |
![]() |
Name of variable(s) to declare | |||||
The C_VARIANT casts each specified variable as a Variant variable. A variant variable can contain any value of the following 4D data types: BLOB, Boolean, Collection, Date, Longint, Object, Picture, Pointer, Real, Text, Time, Null, Undefined.
The first form of the command, in which the optional method parameter is NOT passed, is used to declare and type any process, interprocess or local variable.
Note: This form can be used in both interpreted and compiled databases.
The second form of the command, in which the optional method parameter IS passed, is used to predeclare to the compiler the result and/or the parameters ($0, $1, $2 etc) for a method. Use this form of the command in order to skip the typing of variables phase while compiling a database, saving compilation time.
WARNING: Using a variant rather than a fixed type can reduce performance.
The syntax C_VARIANT(${...}) lets you declare a variable number of parameters of the same type, if they are the last parameters for the method. For example, the declaration C_VARIANT(${5}) tells 4D and the compiler that beginning with the fifth parameter, the method can receive a variable number of parameters of that type. For more information, see the Parameter indirection section.
To verify the type and value of a variant variable:
C_VARIANT($var)
C_LONGINT($vt)
$var:="test"
$vt:=Type($var) //$vt="Is variant"
$vt:=Value type($var) //$vt="Is text"
Product: 4D
Theme: Compiler
Number:
1683
Created: 4D v18
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)