Function overview
Prototype
ValueExists (
value; valuelist )
Parameters
value The needle
valuelist The haystack
Description
Tags:
in_array, in array, in value list, value list
This is the FM equivalent to PHP's in_array() function.
It is a recursive function. It will take a value list (meaning a linebreak delimited value list) and search for an exact match using the input value.
It will return 1 if an exact match is found and 0 if no exact match found.
Examples
Sample input
ValueExists("apple","apple¶pear¶peach¶plum¶cherry")
Sample output
1
Function code
Let(
[
count = ValueCount(valuelist);
curVal = LeftValues(valuelist ; 1)
];
If(
count < 2;
If(Exact ( valuelist ; value ); 1; 0);
If(Exact ( curVal; value & "¶" ) ; 1 ; ValueExists(value; RightValues ( valuelist ; count - 1 )))
)
)
// ===================================
/*
This function is published on FileMaker Custom Functions
to check for updates and provide feedback and bug reports
please visit http://www.fmfunctions.com/fid/230
Prototype: ValueExists( value; valuelist )
Function Author: Delta Tango (http://www.fmfunctions.com/mid/164)
Last updated: 11 June 2009
Version: 2.0
*/
// ===================================
Let(__LITBR__[__LITBR__count = ValueCount(valuelist);__LITBR__curVal = LeftValues(valuelist ; 1)__LITBR__];__LITBR__If(__LITBR__count < 2;__LITBR__If(Exact ( valuelist ; value ); 1; 0);__LITBR____LITBR__If(Exact ( curVal; value & "¶" ) ; 1 ; ValueExists(value; RightValues ( valuelist ; count - 1 )))__LITBR____LITBR__)__LITBR__)__LITBR____LITBR__// ===================================__LITBR__/*__LITBR____LITBR__ This function is published on FileMaker Custom Functions__LITBR__ to check for updates and provide feedback and bug reports__LITBR__ please visit http://www.fmfunctions.com/fid/230__LITBR____LITBR__ Prototype: ValueExists( value; valuelist )__LITBR__ Function Author: Delta Tango (http://www.fmfunctions.com/mid/164)__LITBR__ Last updated: 11 June 2009__LITBR__ Version: 2.0__LITBR____LITBR__*/__LITBR__// ===================================
Login or register to comment
Create a new account with fmcustomfunctions.com or login to post a comment.
Comments
11 June 2009
getasBoolean( valueCount( filterValues( valuelist; value)))
However, if you really need EXACT then some mods would be required.
06 September 2009