ValueExists ( )

Function stats

Average user rating
164
230
9999
Support
FileMaker 7.0 +
Date posted
12 June 2009
Last updated
12 June 2009
Version
Recursive function
Yes

Author Info
 Delta Tango

2 functions

Average Rating None

author_avatar



 

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: 12 June 2009
    Version: 2.0

*/
// ===================================

 

Comments

BruceR
12 June 2009



There is no need for this function to be recursive. It could be defined as
getasBoolean( valueCount( filterValues( valuelist; value)))
However, if you really need EXACT then some mods would be required.
  General comment
Genx
07 September 2009



Or as an alternative, this one gives you position: http://fmfunctions.com/fname/list.find
  General comment

 

 

 

 

 

Top Tags

Text Parsing  (33)
List  (32)
Date  (28)
XML  (27)
Format  (23)
Sql  (22)
Dev  (20)
Debug  (17)
Interface  (15)
Layout  (15)
Text  (14)
Variables  (13)
Filter  (12)
Layout Objects  (11)
Design  (10)
Array  (8)