One Part Harmony – FileMaker Database Design, Development, and Maintenance

Custom Functions: Value Lists & Script Parameters
In_Value_List

Determines if a specified value is present in a specified list of values, and if so, to return the index to the value in that list.

Format
In_Value_List( Value_List , Value )
Parameters
Value_List - A string containing the return-separated list of values to be searched.

Value - The string containing the search value.
Data Type Returned
number / boolean
Examples
Assume the variable $List contains High¶Medium¶Low

Assume the variable
$Value contains Medium

Set Variable[$Index; Value:In_Value_List($List; $Value)]

Then
$Index would now contain 2 (which also evaluates to True)
Description
Returns 0 (False) if the either the value list or the value is empty.

Return
0 (False) if the specified value does not exactly match any item in the value list. (Not case sensitive.)

Returns the index (a positive number indicating the sequence number of the value in the list ... that also evaluates to
True) if the value exactly matches an item in the value list.
FileMaker Versions Supported
7, 8, 8.5, 9, 10, 11, 12, 13, 14, 15, 16
Code
/*
Determines if a specified value is present in a return-separated list of values:

Returns 0 if the either the value list or the value is empty.

Return 0 (False) if the specified value does not exactly match any item in the value list.

Returns the index (a positive number indicating the position of the value in the list ... that also evaluates to True) if the value exactly matches an item in the value list.
*/

Let
(
[
Value = If( Right( Value ; 1 ) = "¶" ; Left( Value ; Length( Value ) - 1 ) ; Value ) ;

FirstCharPos = If( not IsEmpty( Value_List and not IsEmpty( Value ) ) ; Position( "¶" & Value_List & "¶" ; "¶" & Value & "¶" ; 1 ; 1 ) ; 0 )

];

Case
(
FirstCharPos < 1 ; 0 ;
PatternCount( Left( "¶" & Value_List ; FirstCharPos ) ; "¶" )
)

)