OP Copy named selection

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 Copy named selection (connectionID; tableID; selectionName) Longint

ParameterTypeDescription
connectionIDLongintConnection ID with target server
tableIDLongintNumber of the table in the database
selectionNameStringName of the selection
Function resultLongintError code result for the function

Description

OP Copy named selection copies the current selection for tableID to SelectionName. This function does not affect the current selection of tableID.

Error Codes

If OP Copy named selection executes successfully, it returns 0. Otherwise, this function returns one of the following errors:

Error CodeDescription
-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 lets the user create a selection of invoices. Then it launches a background process that prints the selection of invoices while the user continues to work with the selection.

   C_LONGINT($ErrCode;vRecords)

   ARRAY LONGINT(arTableID;0)
   ARRAY LONGINT(arFieldID;0)
   
   ARRAY TEXT(arLogOp;0)
   ARRAY TEXT(arQueOp;0)
   ARRAY TEXT(arValues;0)

   UserSelectInvoices    `Display a dialog that let the user specify his criteria

   ` Perform the query specified by the user
   $errCode := OP Multi query (<>vConnectID;2;arFileID;arFieldID;arLoglOp;arQueOp;arValues;vRecords)
   
   ` Make a copy of [Invoices] current selection into an Interprocess named selection
   $errCode := OP Copy named selection (<>vConnectID;2;"<>Invoices to print")
   ` Using OP Copy instead of OP Cut preserves the current selection for futher usage
   $printProcess := New process ("PrintInvoices";32000;"Background printing")

   ` Let's display the list of invoice for the user to work with
   UserDisplayInvoices
   ...

This is a possible implementation of the 'PrintInvoices' method.

   ` Command PrintInvoices Prints in the background the invoices
   ` designated by the "<>Invoices to print" named selection

   ` Make the current selection a 'replica' of the named selection
   $errCode:= OP Use named selection (<>vConnectID;2;"<>Invoices to print")

   If ($errCode=0)

      ` Clear the named selection to release server memory
      $errCode := OP Clear named selection (<>vConnectID;"<>Invoices to print")
      ` Count records in current selection
      $errCode := OP records in selection (<>vConnectID;2;vRecords)
   
      For ($i;1;vRecords)
         $errCode := OP Goto selected record (<>VconnectID;2;$i)
         PrintOneInvoice (<>vConnectID)
      End for

   End if

See Also

OP Clear named selection, OP Cut named selection, OP Use named selection.


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