This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com |
||||||||||||||
|
4D v20 R7
Compiler Commands
|
_O_C_BLOB | _O_C_REAL | _O_C_TEXT |
_O_C_BOOLEAN | _O_C_LONGINT | _O_C_DATE |
_O_C_POINTER | _O_C_PICTURE | _O_C_TIME |
_O_C_OBJECT | _O_C_VARIANT | IDLE |
Compatibility note: The obsolete _o_C_GRAPH, _o_C_INTEGER and _o_C_STRING commands must no longer be used.
These commands, except IDLE, declare variables and cast them as a specified data type. Declaring variables resolves ambiguities concerning a variable’s data type. If a variable is not declared with one of these commands, the compiler attempts to determine a variable’s data type. The data type of a variable used in a form is often difficult for the compiler to determine. Therefore, it is especially important that you use these commands to declare a variable used in a form.
Note: To save time, you can use the option for generating and updating typing methods (called “Compiler methods”) found in the compiler window. This option automatically creates typing methods that take stock of and assign a type to all of the variables used in the database.
Arrays are variables that must follow the same rules as standard variables with respect to compilation. The array declaration commands are grouped together in the “Arrays” theme.
These principles are detailed in the following sections:
The following are some basic variable declarations for the compiler:
C_BLOB(vxMyBlob) // The process variable vxMyBlob is declared as a variable of type BLOB
C_BOOLEAN(<>OnWindows) // The interprocess variable <>OnWindows is declared as a variable of type Boolean
C_DATE($vdCurDate) // The local variable $vdCurDate is declared as a variable of type Date
C_LONGINT(vg1;vg2;vg3) // The 3 process variables vg1, vg2 and vg3 are declared as variables of type longint
In the following example, the OneMethodAmongOthers project method declares 3 parameters:
// OneMethodAmongOthers Project Method
// OneMethodAmongOthers ( Real ; Date { ; Long } )
// OneMethodAmongOthers ( Amount ; Date { ; Ratio } )
C_REAL($1) // 1st parameter is of type Real
C_DATE($2) // 2nd parameter is of type Date
C_LONGINT($3) // 3rd parameter is of type Long Integer
In the following example, the Capitalize project method accepts a text parameter and returns a text result:
// Capitalize Project Method
// Capitalize ( Text ) -> Text
// Capitalize ( Source string ) -> Capitalized string
C_TEXT($0;$1)
$0:=Uppercase(Substring($1;1;1))+Lowercase(Substring($1;2))
In the following example, the project method SEND PACKETS accepts a time parameter followed by a variable number of text parameters:
` SEND PACKETS Project Method
` SEND PACKETS ( Time ; Text { ; Text2... ; TextN } )
` SEND PACKETS ( docRef ; Data { ; Data2... ; DataN } )
C_TIME($1)
C_TEXT(${2})
C_LONGINT($vlPacket)
For($vlPacket;2;Count parameters)
SEND PACKET($1;${$vlPacket})
End for
In the following example, the COMPILER_Param_Predeclare28 project method predeclares the syntax of other project methods for the compiler:
// COMPILER_Param_Predeclare28 Project Method
C_REAL(OneMethodAmongOthers;$1) // OneMethodAmongOthers ( Real ; Integer { ; Long } )
C_DATE(OneMethodAmongOthers;$2) // ...
C_LONGINT(OneMethodAmongOthers;$3) // ...
C_TEXT(Capitalize;$0;$1) // Capitalize ( Text) -> Text
C_TIME(SEND PACKETS;$1) // SEND PACKETS ( Time ; Text { ; Text2... ; TextN } )
C_TEXT(SEND PACKETS;${2}) // ...
_o_C_GRAPH
_o_C_INTEGER
_o_C_STRING
C_BLOB
C_BOOLEEN
C_DATE
C_LONGINT
C_PICTURE
C_POINTER
C_REAL
C_TEXT
C_TIME
IDLE
Product: 4D
Theme: Compiler
Modified: 4D v15 R5
4D Language Reference ( 4D v20 R7)