Brian Dunning's FileMaker Custom Functions

GetValueIndex ( valueList ; valueString ; matchCase ; occurrence )

Return index to value in valuelist. Search case sensitive or insensitive. Search for occurrence from front or end.

  Average rating: 3.9 (51 votes) Log in to vote

Lewis Lorenz   Lewis Lorenz - Show more from this author
Lorenz Companies
http://www.LorenzCom.com

Share on Facebook Share on Twitter

  Sample input:
GetValueIndex ( "Alpha¶Bravo¶Charlie¶Echo" ; "charlie" ; False ; 1 )
GetValueIndex ( "Alpha¶Bravo¶Charlie¶Echo" ; "charlie" ; True ; 1 )
GetValueIndex ( "James¶Bill¶James¶Frank¶James¶Ed" ; "james" ; False ; -2 )
  Sample output:
3
0
3

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

GetValueIndex (valueList, valueString, matchCase, occurrence)

by Lewis C. Lorenz.
9/20/2011 Created
9/22/2011 Modified.

Retrieve the index of the matching valueString in the valueList.
Returns 0 if not found.
Optionally toggle case-sensitive searching by passing a boolean through matchCase.
Optionally search for specific valueString occurrence (a negative occurrence number causes backward search from the end of the valueList).

NOTICE: While this function is optimized to be single-pass when possible, this is a recursive function; so, if you change the function name remember to also change it in the function code.

Examples:
GetValueIndex ( "Alpha¶Bravo¶Charlie¶Echo" ; "charlie" ; False ; 1 ) = 3
GetValueIndex ( "Alpha¶Bravo¶Charlie¶Echo" ; "charlie" ; True ; 1 ) = 0
GetValueIndex ( "James¶Bill¶James¶Frank¶James¶Ed" ; "james" ; False ; -2 ) = 3

 

Comments

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 15 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth: