version 1.5
OP Define bind by numbers (bindID; tableID; fieldID; localTableID; localFieldID; variableName) Longint
Parameter | Type | Description | |
bindID | Longint | Bind list ID | |
tableID | Longint | Number of table in the database | |
fieldID | Longint | Number of the field in the table | |
localTableID | Longint | Number of the table in the local database | |
(0 if bind to variable) | |||
localFieldID | Longint | Number of the field in the local table | |
(0 if bind to variable) | |||
variableName | String | Name of the variable or array | |
("" if bind to field) | |||
Function result | Longint | Error code result for the function |
Description
OP Define bind by numbers adds a bind to the bindID bind list for tableID and fieldID on the server, indicated by passing their numbers.
For example, to bind the [Invoices]Invoice ID, and Invoice ID is the first field in the [Invoices] table, which is the second file on the server database, pass 1 as fieldID and 2 as tableID.
In the same way, if you bind a field from the server to a local field, pass the numbers of the table and field to localTableID and to localFieldID and "" to variableName.
To bind tableID and fieldID to a local object such as a variable or an array, pass its name to variableName and pass 0 to localTableID and localFieldID.
variableName can be an interprocess or process variable or array name. variableName cannot be a local variable or array (i.e., using the dollar sign "$").
Error Codes
If OP Define bind by numbers executes successfully, it returns 0. Otherwise, this function returns one of the following errors:
Error Code | Description |
-108 | Not enough memory to perform this operation. |
10128 | The 4D Open for 4th Dimension package has not been initialized. |
10137 | The bind list does not exist. |
10140 | The local field does not exist. |
10141 | The local table does not exist. |
10142 | You cannot bind this type of field. |
10154 | This command cannot be executed right now. |
10157 | Duplicated bind entry. |
Example
This example lists binds between the [Invoices] table fields and several arrays to be used as scrollable areas on a form. This would be a way to display a list of invoices to the user.
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 numbers ($BindID;vTableInvoices;vFieldCustID;0;0;"aCustID") $ErrCode := $ErrCode + OP Define bind by numbers ($BindID;vTableInvoices;vFieldCustID;0;0;"aInvDate") $ErrCode := $ErrCode + OP Define bind by numbers ($BindID;vTableInvoices;vFieldAmount;0;0;"aInvTotal") $ErrCode := $ErrCode + OP Define bind by numbers ($BindID;vTableCustomers;vFieldCity;0;0;"aCity") $ErrCode := $ErrCode + OP Define bind by numbers ($BindID;vTableCustomers;vFieldCompany;0;0;"aCompany") ` On a known stable structure one could also write ` $ErrCode := $ErrCode + OP Define bind by numbers ($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 pointer, OP Delete bind, OP Load record, OP Selection to array.