ACF Library

vlDifference

Back to List

Description: Return the difference between two valuelists.

FileMaker Prototype:

Set Variable [$res; ACF_Run("vlDifference"; string_setA;  string_setB)]

Category: UTILITY

Dependencies

Function source:

function vlDifference (string setA, string setB)
   
   setA = NormalizeCRs ( setA); 
   setB = NormalizeCRs ( setB); 
   array string aSetA = explode ("\r", setA); 
   array string aSetB = explode ("\r", setB);
   Array string aResult; 
   int i, SzA; 
   SzA = sizeof (aSetA);  
   for (i=1, SzA)
      if ( find_in_array(aSetB, aSetA[i]) < 0) then
         aResult[] = aSetA[i]; 
      end if
   end for
    
   return Implode ("\r", aResult); 
end

The vlDifference Function returns the difference of two value lists, i.e. only the unique values from "SetA" that is not present in "SetB"

  • Similar to the intersection function, it splits the input strings into arrays.

  • It iterates through aSetA and checks whether each element is not found in aSetB (i.e. find_in_array returns a negative value).

  • Elements that are unique to setA are added to aResult.

  • The function then returns the result as a newline-separated string.

Example

Set Variable [$res; ACF_Run("vlDifference"; string_setA;  string_setB)]

String_setA: 
banana
orange
apple

String_setB:
potatoes
orange
apple
kiwi

The result: 
banana
Back to List