Brian Dunning's FileMaker Custom Functions

cf_getElementNo ( SearchString ; ElementList )

Get the line number of sought-after element in a list

  Average rating: 4.4 (34 votes) Log in to vote

Klemens Müller   Klemens Müller - Show more from this author
Klemens Müller

Share on Facebook Share on Twitter

  Sample input:
cf_getElementNo( "gamma" ; "Alpha¶Beta¶Gamma¶Delta¶Epsilon" )
  Sample output:

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

Determines the number of first occurenc of the sought-after element in a list of elements



Oliver Reid   Oliver Reid
Feb 28, 2009
I believe this will not work if a an earlier list element contains a later one:



and you search for 'gamma'
Oliver Reid   Oliver Reid
Feb 28, 2009
On reflection I suggest this change:

fpos = Position( ¶&clist&¶ ; ¶&spos&¶ ; 1 ; 1 ) + Length( spos )+1 ;
John Jackson   John Jackson, Santa Rosa CA USA
Aug 22, 2010
This won't work if SearchString isn't in ElementList in the first place; it will return a value anyways.
John Jackson   John Jackson, Santa Rosa CA USA
Aug 22, 2010
Here's a revised version:
Parameters: element_list, search_string

Let( [
s_pos = Position ( ¶&element_list&¶ ; ¶&search_string&¶ ; 1 ; 1 ) ;
f_pos = s_pos + Length ( search_string ) - 1 ;
f_list = Middle ( element_list ; 1 ; f_pos ) ;
index = ValueCount ( f_list )
] ;
If ( s_pos ;
index ;
Edward Souza   Edward Souza, Sao Paulo, BR
Sep 12, 2010
Hello, all,

Well done, Mr. Jackson. Thanks for sharing. :-)

Log in to post comments.


Note: these functions are not guaranteed or supported by 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 16 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: