4D Server, Sets and Named Selections

4D - Documentation   Français   English   German   4D Server, Theme List   4D Server, Index   Back   Previous   Next

version 11.2 (Modified)


As explained in the Sets and Named Selections sections of the 4D Language Reference manual, you can work with interprocess, process, and local sets and named selections:

Process sets/named selections: A process object can only be accessed by the process in which it has been created and, if it has been created in a client process, by the "twinned" process created on the server. UserSet and LockedSet are process sets. Process sets are cleared as soon as the process method ends. Process objects do not need any special prefix in the name.

Interprocess sets/named selections: An interprocess object is visible for all the processes on the machine (client or server) where it was created. A set or named selection is an interprocess object if the name of the set is preceded by the symbols (<>) — a "less than" sign followed by a "greater than" sign. Note: This syntax can be used on both Windows and Macintosh. Also, on Macintosh only, you can use the diamond symbol (Option-Shift-V on a US keyboard).

Local/Client sets/named selections: A local/client object is only visible in the process where it was created. The name of a local/client object is preceded by the dollar sign ($). Note: Although its name does not begin with a $, the UserSet system set is a local/client set.

The following table indicates the principles concerning the visibility of named selections and sets according to where they are created (the table is identical for both types of objects):

x = visible

You need to keep this visibility matrix in mind depending on the operations you want to perform. For example, if you want to do an INTERSECTION type operation, make sure that all the sets are visible on the machine that is carrying out the operation.

For optimization purposes, it is recommended to choose the creation location and the scope of the objects according to their visibility requirements.

4D in remote mode creates the UserSet as a local set (although its name does not begin with a $) for optimizing the creation of a set according to the user actions performed in a MODIFY SELECTION or DISPLAY SELECTION form.

If you plan to pass UserSet as a parameter to DIFFERENCE, INTERSECTION or UNION when the other parameters are interprocess or process sets, you must first copy UserSet (a local set) into an interprocess or process set and use that set with the command.

Example:

   ALL RECORDS ([aTable])
      ` Let the user select some records
   MODIFY SELECTION ([aTable];*)
      ` Check if the user has selected some records
   If (Records in set("UserSet")>0)
         ` Query the records to be excluded
      QUERY([aTable];[aTable]aFlag#0)
         ` Create a set from the resulting selection
      CREATE SET([aTable];"To be excluded")
      If (Application type = 4D Remote Mode)
            ` UserSet is local set, copy it to a non-local set
         COPY SET ("UserSet";"UserSelection") `  Copied over the network
            ` Call DIFFERENCE passing 3 non-local set parameters
         DIFFERENCE ("UserSelection";"To be excluded";"UserSelection")
      Else
            ` Call DIFFERENCE
         DIFFERENCE ("UserSet";"To be excluded";"UserSelection")
      End if
      CLEAR SET ("To be excluded")
      USE SET("UserSelection")
      CLEAR SET ("UserSelection")
   End if

The same thing can be achieved with the following code:

   ALL RECORDS ([aTable])
      ` Let the user select some records
   MODIFY SELECTION ([aTable];*)
      ` Check if the user has selected some records
   If (Records in set("UserSet")>0)
         ` Query the records to be excluded
      QUERY([aTable];[aTable]aFlag#0)
      If (Application type = 4D Remote Mode)
            ` Create a local set from the resulting selection
         CREATE SET([aTable];"$To be excluded") `  Copied from Server to Client
            ` Call DIFFERENCE passing 3 local set parameters
         DIFFERENCE ("UserSet";"$To be excluded";"UserSet")
      Else
            ` Create a non-local set from the resulting selection
         CREATE SET([aTable];"To be excluded")
            ` Call DIFFERENCE
         DIFFERENCE ("UserSet";"To be excluded";"UserSelection")
      End if
      CLEAR SET("$To be excluded")
      USE SET("UserSet") `  Copied from Client to Server
   End if

In the first example, three sets are created and one is copied over the network. In the second example, two sets are created and two are copied over the network. Depending on your needs, choose a solution similar to one of these examples.

4D Server and the LockedSet


The LockedSet is a process set that is visible in the process and on the machine where it was created, as well as in the trigger on the server machine.

See Also

4D Server and the 4D Language, COPY SET, Sets.


4D - Documentation   Français   English   German   4D Server, Theme List   4D Server, Index   Back   Previous   Next