Brian Dunning's FileMaker Custom Functions

cfGetEveryNthValue ( pList ; pStart ; pIncrement ; pInputSeparator ; pOutputSeparator )

Extract every Nth item from a list; allow starting value and list separators to be specified

  Average rating: 4.2 (43 votes) Log in to vote

Kevin Frank   Kevin Frank
Kevin Frank & Associates
http://www.kevinfrank.com

Share on Facebook Share on Twitter

  Sample input:
cfGetEveryNthValue ( "A~B~C~D~E~F" ; 2 ; 3 ; "~" ; "$" )
  Sample output:
B$E

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

Recently I needed to reduce a list to "every other" item in that list, i.e., the 1st item, the 3rd item, the 5th item, etc.

It occurred to me that in the future I might need, say, every third item rather than every other item, and that I might want to begin with something other than the first item on the list. It also occurred to me that I might want to specify a list separator other than a hard return, for either the input, the output, or both.

That's how this CF came to be.

 

Comments

David Nahodyl   David Nahodyl, Atlanta, GA
May 9, 2015
This worked perfectly for what I needed to do. Giant list of 2800 points to graph, more than necessary and more than WebDirect could handle in a graph. I was about to write my own function and came across this by chance for another project. Thanks for posting this!
 

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 20 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: