ACF Library

vlIntersection

Back to List

Description: Return the intersection between two value lists

FileMaker Prototype:

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

Category: UTILITY

Dependencies

Function source:

function vlIntersection (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 vlIntersection is used to compare two value lists and return a value list with only the common values from both.

  • The function splits both input strings into arrays using the newline separator.

  • It then iterates over each element in aSetA and checks if the element exists in aSetB (using find_in_array).

  • The condition > 0 implies that the arrays are 1-indexed.

  • Elements found in both lists are appended to aResult.

  • Finally, the returned result is combined into a single string with newline separators.

Example

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

String_setA: 
banana
orange
apple

String_setB:
potatoes
orange
apple
kiwi

The result: 
orange
apple
Back to List