version 6.0.2
As explained in the section Sets of the 4th Dimension Language Reference manual, you can work with interprocess, process, and local sets:
Process sets: A process set can only be accessed by the process in which it has been created. UserSet and LockedSet are process sets. Process sets are cleared as soon as the process method ends. Process sets do not need any special prefix in the name.
Interprocess sets: A set is an interprocess set 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 Sets/Client Sets: The name of a local/client set is preceded by the dollar sign ($). Note: Although its name does not begin with a $, the UserSet system set is a local/client set.
With 4D Server, interprocess and process sets are maintained on the server machine, while local sets are maintained on the client machines.
Tip: Usually, you will use interprocess and process sets because they optimize set handling in Client/Server architecture.
4D Server and the Sets Commands
This section describes the behavior of the Sets commands in Client/Server architecture when they are executed on the Client machine:
The empty set is created on the server machine. A local set is then copied over the network from the server machine to the client machine. An interprocess or a process set stays and is maintained on the server machine.
The set is created on the server machine. A local set is then copied over the network from the server machine to the client machine. An interprocess or a process set stays and is maintained on the server machine.
USE SET
A local set is first copied over the network from the client machine to the server machine, then it is used on the server machine to change the selection of the table. An interprocess or process set is used locally on the server machine to change the selection of the table.
SAVE SET
A local set is saved locally on the client machine.
An interprocess or process set is first copied over the network from the server machine to the client machine, then is saved locally on the client machine
LOAD SET
A local set is loaded from the disk locally on the client machine.
An interprocess or process set is first loaded from the disk locally on the client machine, then is copied over the network from the client machine to the server machine.
These five commands access a local set locally on the client machine. With an interprocess or process set, a request is sent over the network to the server machine to get the information or perform the action.
UNION
These three commands require the three set parameters to be on the same machine. Consequently, they must be all local sets or none of them must be local.
COPY SET
Using COPY SET, you can copy any set into another one. For example, you can copy a local set into an interprocess or process set. In this case, the set is copied over the network from the client machine to the server machine.
4D Server and the UserSet
4D Client 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 Client) ` 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 Client) ` 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 created and maintained on the server machine.
See Also
COPY SET, Named Selections, Sets.