vlUnion
Back to ListDescription: Returns all unique values from both "SetA" and "SetB".
FileMaker Prototype:
Set Variable [$res; ACF_Run("vlUnion"; string_setA; string_setB)]
Category: UTILITY
Dependencies
- find_in_array: Find an item in an ACF array
- NormalizeCRs: Replace CRLF and LF to CR in a string (Value list)
Function source:
function vlUnion (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, SzB;
SzA = sizeof (aSetA);
for (i=1, SzA)
if ( find_in_array(aResult, aSetA[i]) < 0) then
aResult[] = aSetA[i];
end if
end for
SzB = sizeof (aSetB);
for (i=1, SzB)
if ( find_in_array(aResult, aSetB[i]) < 0) then
aResult[] = aSetB[i];
end if
end for
return Implode ("\r", aResult);
end
The vlUnion Function returns the UNION of two valuelists.
-
The function creates arrays from the two input strings.
-
It first loops through all elements of
aSetA
and adds them toaResult
if they are not already present. -
In the second loop, it adds elements from
aSetB
that are not already inaResult
.
Example
Set Variable [$res; ACF_Run("vlUnion"; string_setA; string_setB)]
String_setA:
banana
orange
apple
String_setB:
potatoes
orange
apple
kiwi
The result:
banana
orange
apple
potatoes
kiwi