Using the 4D Open for 4D Routines

4D - Documentation   Français   English   German   4D Open for 4D, Command Theme List   4D Open for 4D, Command Alphabetical List   Back   Previous   Next

version 6.0 (Modified)


All 4D Open for 4th Dimension (4D Open for 4D) plug-in routines are functions. Each function returns an error code result that tells you whether or not the operation was successfully performed. If the function returns 0, no error has occurred.

4D Open for 4D functions should always be assigned a Long Integer (Longint) variable that will receive the error code. The following code shows you how to use a 4D Open for 4D function:

       ` Do something and get error code result
   $errCode:=OP Set option (3;1)

Some 4D Open for 4D routines such as OP Get field properties return values as well as error codes. The values are returned in the parameters, and the error code is returned in the Longint variable assigned to the routine. In the following line of code, the error code is returned in $errCode, and the values returned by the routine are placed into the parameters (which have been previously declared). The connID and tabID parameters are passed to this function to retrieve information about them in the other parameters:

   $errCode:=OP Get field properties (connID;tabID;tabInv;fNames;fTypes;fLen;fIndex;fInv)

Nature of the parameters passed to 4D Open for 4D routines

The types of parameters passed to a routine depend on whether the routine returns a value in the parameter and whether or not the parameter refers to a 4th Dimension object.

Parameters not returning a value

You can pass an expression, a field, a variable (local, process, or interprocess) or an array (process or interprocess).

You cannot pass local arrays.

Since you are working in a multi-process environment, if you pass interprocess variables or arrays, be sure to protect the use of these variables and arrays by using local semaphores.

Examples:

   $ErrCode:=OP Enter password (arUser;$UserName;$Password)
   $ErrCode:=OP Enter password (<>arUser;$UserName;$Password)

Parameters returning a value

You can pass a field, a variable (local, process, or interprocess) or an array (process or interprocess).

You cannot pass local arrays.

Since you are working in a multi-process environment, if you pass interprocess variables or arrays, be sure to protect the use of these variables and arrays by using local semaphores.

Examples:

   $ErrCode:=OP Count tables ($ConnID;[Servers]NbFiles)
   $ErrCode:=OP Count tables ($ConnID;$NbFiles)
   $ErrCode:=OP Count tables ($ConnID;NbFiles)
   $ErrCode:=OP Count tables ($ConnID;<>NbFiles)
   $ErrCode:=OP Get all tablenames ($ConnID;arFName)
   $ErrCode:=OP Get all tablenames ($ConnID;<>arFName)

Parameters referring to a 4D object (fields, variables, arrays)

You can pass a reference to a field (pointer or number) or to a process or interprocess variable or array (pointer or name).

You cannot pass a pointer to an array element.

You cannot pass a reference to a local variable or array.

Since you are working in a multi-process environment, if you pass interprocess variables or arrays, be sure to protect the use of these variables and arrays by using local semaphores.

Note: You can get/set BLOB fields in the same way you do it with other fields.

Examples:

   $ErrCode:=OP Single query ($ConnID;$FileID;$FieldID;"=";»[Data]Value;$NbFound)
   $ErrCode:=OP Single query ($ConnID;$FileID;$FieldID;"=";»vValue;$NbFound)
   $ErrCode:=OP Single query ($ConnID;$FileID;$FieldID;"=";»<>vValue;$NbFo und)
   $ErrCode:=OP Define bind by numbers ($BindID;10;4;2;4;"") 
   $ErrCode:=OP Define bind by numbers ($BindID;10;4;0;0;"vName")
   $ErrCode:=OP Define bind by numbers ($BindID;10;4;0;0;"<>vName")
   $ErrCode:=OP Define bind by numbers ($BindID;10;4;0;0;"arValue")
   $ErrCode:=OP Define bind by numbers ($BindID;10;4;0;0;"<>arValue")
   $ErrCode:=OP Define bind by pointer ($BindID;10;4;»vName)
   $ErrCode:=OP Define bind by pointer ($BindID;10;4;»<>vName)
   $ErrCode:=OP Define bind by pointer ($BindID;10;4;»arValue)
   $ErrCode:=OP Define bind by pointer ($BindID;10;4;»<>arValue)

What you should know

To use 4D Open for 4D, you should be familiar with the 4th Dimension programming language.

What you need

To use 4D Open for 4D, you must have 4D Server and either 4D Client or 4th Dimension.

All version numbers must match; for example with 4D Open 4D 2003 you must use 4D Server 2003 as well as 4D Client or 4th Dimension 2003. You cannot mix different versions.


4D - Documentation   Français   English   German   4D Open for 4D, Command Theme List   4D Open for 4D, Command Alphabetical List   Back   Previous   Next