4D v16.3

DIFFERENCE

Home

 
4D v16.3
DIFFERENCE

DIFFERENCE 


 

DIFFERENCE ( set1 ; set2 ; resultSet ) 
Parameter Type   Description
set1  String in Set
set2  String in Set to subtract
resultSet  String in Resulting set

DIFFERENCE compares set1 and set2 and excludes all records that are in set2 from the resultSet. In other words, a record is included in the resultSet only if it is in set1, but not in set2. The following table shows all possible results of a set Difference operation.

Set1Set2Result Set
YesNoYes
YesYesNo
NoYesNo
NoNoNo

The result of a Difference operation is depicted here. The shaded area is the result set.

The resultSet is created by DIFFERENCE. The resultSet replaces any existing set having the same name, including set1 and set2. Both set1 and set2 must be from the same table. The resultSet belongs to the same table as set1 and set2.

4D Server: In Client/Server mode, sets are "visible" depending on their type (interprocess, process and local) and where they were created (server or client). DIFFERENCE requires all three sets to be visible on the same machine. See the paragraph 4D Server, Sets and Named Selections in the 4D Server Reference manual for more information.

Example  

This example excludes the records that a user selects from a displayed selection. The records are displayed on screen with the following line:

 DISPLAY SELECTION([Customers]//Display the customers in a list

At the bottom of the list of records is a button with an object method. The object method excludes the records that the user has selected (the set named “UserSet”), and displays the reduced selection:

 CREATE SET([Customers];"$Current") //Create a set of current selection
 DIFFERENCE("$Current";"UserSet";"$Current") //Exclude selected records
 USE SET("$Current") //Use the new set
 CLEAR SET("$Current") //Clear the set



See also 

INTERSECTION
UNION

 
PROPERTIES 

Product: 4D
Theme: Sets
Number: 122

This command can be run in preemptive processesDifferent in remote mode

 
HISTORY 

Created: < 4D v6

 
ARTICLE USAGE

4D Language Reference ( 4D v16)
4D Language Reference ( 4D v16.1)
4D Language Reference ( 4D v16.2)
4D Language Reference ( 4D v16.3)