OP Define bind by pointer

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

version 1.5


OP Define bind by pointer (bindID; tableID; fieldID; boundObject) Longint

ParameterTypeDescription
bindIDLongintBind list ID
tableIDLongintNumber of the table in the database
fieldIDLongintNumber of the field if the table
boundObjectPointerPointer on object to bind
Function resultLongintError code result for the function

Description

OP Define bind by pointer is similar to OP Define bind by numbers. However, OP Define bind by pointer takes a pointer to the local object: field, variable, or array. This syntax allows for more flexibility when one does not know in advance what local objects are going to be bound.

OP Define bind by pointer adds a bind to bindID bind list for tableID and fieldID on the server, indicated by passing their numbers.

In boundObject, pass a pointer to a field in the local database, to a variable or to an array. For example, you can pass ->[AFile]AField,->Var, -><>Var,->Array1, or -><>Array1. Variables or arrays can be process or interprocess only.

Error Codes

If OP Define bind by pointer executes successfully, it returns 0. Otherwise, this function returns one of the following errors:

Error CodeDescription
-108Not enough memory to perform this operation.
10128The 4D Open for 4th Dimension package has not been initialized.
10137The bind list does not exist.
10140The local field does not exist.
10141The local table does not exist.
10142You cannot bind this type of field.
10144The 4D pointer is equal to NIL.
10145A 4D pointer was expected.
10154This command cannot be executed right now.
10157Duplicated bind entry.

Example

This example is essentially the same as the example for OP Define bind by numbers, except that it will carries out the definitions using pointers rather than variable names.

   C_LONGINT ($BindID;$ErrCode;$ConnectID)

   ARRAY DATE (aInvDate;0)
   ARRAY REAL (aInvTotal;0)
   ARRAY STRING (30;aCity;0)
   ARRAY STRING (30;aCustID;0)
   ARRAY STRING (30;aCompany;0)

   C_LONGINT (vTableInvoices;vTableCustomers;$unused1)
   C_LONGINT (vFieldDate;vFieldAmount;vFieldCustID;$unused2)
   C_LONGINT (vFieldCompany;vFieldCity)

   ` Get [Invoices] tableID and [Invoices]Invoice date fieldID
   $errCode:=OP Get one field number (vConnectID;"[Invoices]Invoice date";vTableInvoices;vFieldDate)
   ` Get [Invoices]Invoice amount fieldID   
   $errCode:=OP Get one field number (vConnectID;"[Invoices]Invoice amount";$unused1;vFieldAmount)
   ` Get [Invoices]Customer ID fieldID   
   $errCode:=OP Get one field number (vConnectID;"[Invoices]Customer ID";$unused1;vFieldCustID)
   ` Get [Customers] tableID and [Customers]Company fieldID
   $errCode:=OP Get one field number (vConnectID;"[Customers]Company";vTableCustomers;vFieldCompany)
   ` Get [Customers]City fieldID
   $errCode:=OP Get one field number (vConnectID;"[Customers]Company";$unused1;vFieldCity)

      `…Connect to the server
      `…Perform a query on invoices to create a selection of records

   $ErrCode := OP Create bind ($BindID)
   $ErrCode := $ErrCode + OP Define bind by pointer ($BindID;vTableInvoices;vFieldCustID;->aCustID)
   $ErrCode := $ErrCode + OP Define bind by pointer ($BindID;vTableInvoices;vFieldCustID;->aInvDate)
   $ErrCode := $ErrCode + OP Define bind by pointer ($BindID;vTableInvoices;vFieldAmount;->aInvTotal)
   $ErrCode := $ErrCode + OP Define bind by pointer ($BindID;vTableCustomers;vFieldCity;->aCity)
   $ErrCode := $ErrCode + OP Define bind by pointer ($BindID;vTableCustomers;vFieldCompany;->aCompany)
   ` On a known stable structure one could also write
   ` $ErrCode := $ErrCode + OP Define bind by pointer ($BindID;1;2;0;0;->aCompany)
   
   If ($ErrCode=0)
      $ErrCode:=OP Selection to array ($ConnectID;$BindID)
   End if 

   $ErrCode:=OP Delete bind ($BindID)

See Also

OP Create bind, OP Define bind by numbers, OP Delete bind.


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