ListIndex ( list ; string ; matchcase )
Seaches a list and returns the indexnumber if found
Average rating: 4.5 (33 votes) Log in to vote
Theo Ros - Show more from this author |
Function definition: (Copy & paste into FileMaker's Edit Custom Function window)
Searches a Return delimited list 'list' for the occurrance of the given value.
Returns the 1-based indexnumber if found, 0 if value is not in the list.
Syntax: ListIndex ( list ; value ; matchcase )
In: list - the return delimited list to search
string - the string to look for in the item
matchcase - if True, the list is searched Case Sensitive
if False, a Case Insensitive search is performed
Return type: Number
Comments
Peter Sijmons, Szienz Mar 10, 2014 |
||
list has become a reserved word in FMP13 and can no longer be used as param | ||
Luc Thomaere Apr 9, 2021 |
||
This function gives wrong results when searching for values that are substrings of other values: ListIndex ( "John¶Paula¶George¶Ringo¶Paul" ; "Paul" ; False ) doesn't give 5 Better is: (parameters: MyList, MyValue) Let ( [ marker = "@*!|" ; t = Substitute ( "¶" & ListID & "¶" ; "¶" & ID & "¶" ; "¶" & marker & "¶") ; t = If ( Left ( t ; 1 ) <> "¶" ; "¶" & t ; t ) ; pos = Position ( t ; marker ; 1 ; 1 ) ; index = PatternCount ( Left ( t ; pos ) ; "¶" ) ] ; index ) |
||
Luc Thomaere Apr 9, 2021 |
||
Correction (with right parameter names): Let ( [ marker = "@*!|" ; t = Substitute ( "¶" & MyList & "¶" ; "¶" & MyValue & "¶" ; "¶" & marker & "¶") ; t = If ( Left ( t ; 1 ) <> "¶" ; "¶" & t ; t ) ; pos = Position ( t ; marker ; 1 ; 1 ) ; index = PatternCount ( Left ( t ; pos ) ; "¶" ) ] ; index ) |
||
Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.