Created
January 4, 2014 00:48
-
-
Save dansmith65/8249869 to your computer and use it in GitHub Desktop.
FileMaker Custom Function: ListContains ( ValueList ; ValuesToTestExistence )
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ListContains ( ValueList ; ValuesToTestExistence ) | |
PURPOSE: | |
Test if all specified values exist in a list. | |
PARAMETERS: | |
ValueList (text) values to search in | |
ValuesToTestExistence (text) value(s) to search for | |
RETURNS: | |
(bool) True if ALL values exist in the list | |
DEPENDENCIES: | |
none | |
NOTES: | |
This function is approx. 25% slower than using a function like this, for a single value: | |
Not IsEmpty( FilterValues( ValueList ; SingleValue ) ) | |
REVISIONS: | |
2012-AUG-31 - Created by Dan Smith dansmith65@gmail.com | |
####################################################################################################*/ | |
Let([ | |
~count = ValueCount( ValuesToTestExistence ) | |
]; | |
If( | |
~count = 0 ; | |
False ; | |
// else | |
// test first value | |
If( | |
IsEmpty( FilterValues( | |
ValueList ; | |
GetValue( ValuesToTestExistence ; 1 ) | |
) ) ; | |
// value not found | |
False ; | |
// else | |
// value found | |
If( | |
~count = 1 ; | |
// this is the last value, and it was found | |
True ; | |
// else | |
// test next value | |
ListContains( | |
ValueList ; | |
RightValues( | |
ValuesToTestExistence ; | |
~count - 1 | |
) | |
) | |
) | |
) | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment