OP Goto selected record

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 Goto selected record (connectionID; tableID; recordNumber{; bindID{; lockStatus}}) Longint

ParameterTypeDescription
connectionIDLongintConnection ID with target server
tableIDLongintNumber of the table in the database
recordNumberLongintRelative position of record in the current selection
bindIDLongintBind list ID
lockStatusLongintLock status = 1 means the record is locked
Function resultLongintError code result for the function

Description

OP Goto selected record moves the current record pointer to the specified record in the current selection in tableID and makes that record the current record. The current selection for tableID is not altered.

If you pass 0 in bindID or omit the last two parameters, OP Goto selected record changes only the current record pointer. If you pass a valid bind list ID, the function downloads the fields accordingly. In this case, if the access mode to the table is read/write, the function will also try to give you access to the record in read/write mode. If this operation is successful, the function returns 0 in lockStatus. If the record is already in use by another process, the function returns 1 in lockStatus.

By testing the lockStatus parameter, you know whether or not you can subsequently modify or delete the record using OP Update record or OP Delete record.

If you obtained the current record in read/write mode, after you are done with the record (unless you deleted it), you must release it for the other processes by using OP Unload record.

Error Codes

If OP Goto selected record executes successfully, it returns 0. Otherwise, this function returns one of the following errors:

Error CodeDescription
-9968Invalid selected record number requested.
-9972Table number is out of range.
10128The 4D Open for 4th Dimension package has not been initialized.
10136The connection does not exist.
10154This command cannot be executed right now.

Example

This example implements the PrintCustomerRecords method used in other examples. This method prints all records in the current selection of the [Customers] table.

   C_LONGINT (vTable;$unused1)
   C_LONGINT (vFieldID;vFieldCompany;vFieldAddress;vFieldZip;vFieldCity;vFieldState)
   C_STRING (10;vCustID)
   C_STRING (30;vCustName;vCustCity)
   C_STRING (5;vCustZip)
   C_STRING (2;vCustState)
   C_TEXT (vCustAddress)
   C_LONGINT (vRecords;lockStatus)

   ` Get [Customers] tableID and [Customers]Customer ID fieldID
   $errCode:=OP Get one field number (vConnID;"[Customers]Customer ID";vTable;vFieldID)
   ` Get [Customers]Company fieldID
   $errCode:=OP Get one field number (vConnID;"[Customers]Company";$unused1;vFieldCompany)
   ` Get [Customers]Address fieldID
   $errCode:=OP Get one field number (vConnID;"[Customers]Address";$unused1;vFieldAddress)
   ` Get [Customers]Zip code fieldID
   $errCode:=OP Get one field number (vConnID;"[Customers]Zip code";$unused1;vFieldZip)
   ` Get [Customers]City fieldID
   $errCode:=OP Get one field number (vConnID;"[Customers]City";$unused1;vFieldCity)
   ` Get [Customers]State fieldID
   $errCode:=OP Get one field number (vConnID;"[Customers]State";$unused1;vFieldState)
   
   ` Define the bind list that we will use to load the records to print
   $ErrCode := OP Create bind ($BindID)
   $ErrCode := $ErrCode + OP Define bind by pointer ($BindID;vTable;vFieldID;->vCustID)
   $ErrCode := $ErrCode + OP Define bind by pointer ($BindID;vTable;vFieldCompany;->vCustName)
   $ErrCode := $ErrCode + OP Define bind by pointer ($BindID;vTable;vFieldAddress;->vCustAddress)
   $ErrCode := $ErrCode + OP Define bind by pointer ($BindID;vTable;vFieldZip;->vCustZip)
   $ErrCode := $ErrCode + OP Define bind by pointer ($BindID;vTable;vFieldCity;->vCustCity)
   $ErrCode := $ErrCode + OP Define bind by pointer ($BindID;vTable;vFieldState;->vCustState)

   ` The CustRecords form contains the variable that will be loaded through the bind list
   OUTPUT FORM ([Dialogs];"CustRecords")
   $i := 1
   ` Get the number of records in the current selection of [Customers]
   $errCode := OP Records in selection (vConnID;vTable;vRecords)

   While ($i <= vRecords)
      $errCode := OP Goto selected record (vConnID;vTable;$i;$BindID;LockStatus)
      `Values are loaded, print them with the print record command
      PRINT RECORD ([Dialogs])
      $i := $i +1
   End while

   $errCode := OP Delete bind ($BindID)

See Also

OP Get record numbers, OP Goto record.


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