package NamedSelection;

import j4d.open.*;

class Examplet {

  /* doCopyNamedSelection create a selection and name it
  / first, we select all records of the table 2.
  / Then, we reduce the selection to its half.
  / Then, we create a new selection named "My_Beautifull_Selection"
  */
  public void doCopyNamedSelection(opProcess process) throws opException {

    int targetTable = 2;

    try{
      opTable mTable = new opTable(targetTable);
      opSelection mSelection = process.AllRecords(mTable);

      mSelection.mRecordsInSelection = (mSelection.mRecordsInSelection - 1) / 2;
      process.ReduceSelection(mSelection);

      mSelection = new opSelection(targetTable, "My_Beautifull_Selection");
      process.CopyNamedSelection(mSelection);

    }
    catch (opException er){throw er;}
  }
}