Brian Dunning's FileMaker Custom Functions

ApplyToList ( ListA ; function, separator )

Apply FUNCTION to each item in list

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

Bruce Robertson   Bruce Robertson - Show more from this author

Share on Facebook Share on Twitter

  Sample input:
applyToList( list( invoiceItems::ProductID); "[n]"; ", " )
Evaluate(
applyToList( list( invoiceItems::amount); "[n]"; "+" )
)
  Sample output:
XL123, SM234, P0001

237.50

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

Given a list, apply a function to each item in the list and return the results separated by separator. Rather than walking a range from N1 to N2, this merely walks a list of supplied values. This is a recursive function. The range functions are great but sometimes you need to work with a list.

Use [n] notation to identify item in list.

applyToList( $$array ; "Case( Left( [n] ; 1)=1; [n])"; ", " )
=>
1 Adak, 10 Anchor Point, 11 Anchorage, 12 Anchorage, 13 Anchorage, 14 Anchorage, 15 Anchorage, 16 Anchorage, 17 Anchorage, 18 Anchorage, 19 Anchorage

 

Comments

Dan Shockley   Dan Shockley
Apr 11, 2013
I noticed this function and the one by Debi Fuchs (found at http://www.briandunning.com/cf/899 ) have the exact same name, but the first two parameters are in reverse order compared to each other. That could lead to some serious confusion. Also, the function by Debi Fuchs handles potential errors much more thoroughly.

Just a heads-up to anyone looking at these functions.
 
Bruce Robertson   Bruce Robertson
Apr 11, 2013
Thanks. Looks like she went further with a more robust implementation of the idea.
 

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: