Brian Dunning's FileMaker Custom Functions

mkForDo ( LoopVariable ; StartValueNum ; EndValueNum ; Function )

Implements a For...Do loop to run a function a fixed number of times with an increasing counter

  Average rating: 3.0 (2 votes) Log in to vote

Mike Kupietz   Mike Kupietz - Show more from this author

Share on Facebook Share on Twitter

  Sample input:
mkForDo (
"counter" ;
3 ;
6 ;
"counter & \"^2+1 = \" & counter * counter + 1 & \" ... \" "
  Sample output:
"3^2+1 = 10 ... 4^2+1 = 17 ... 5^2+1 = 26 ... 6^2+1 = 37 ... "

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

This function implements the equivalent of a For...Do loop in FileMaker.

It essentially works like Evaluate(), except it allows you to specify a variable name, and a start value and end value, and it re-Evaluates the expression once for each value of the variable. It does not insert newlines between successive evaluations, it simply concatenates them.

For instance, if you had a table "Data" with fields "Name" and City, and as follows...

Name, City:
"Alice", "Amsterdam"
"Bob", "Boston",
"Carol", "Cleveland"


mkForDo (
1 ;
count(data::Name) ;
"\"COUNTER. The person named \"&getNthRecord(data::Name,COUNTER)&\" lives in \"& getNthRecord(data::city,COUNTER)*\". \"")

Would produce the output:
"1. the person named Alice lives in Amsterdam. 2. the person named Bob lives in Boston. 3. the person named Carol lives in Cleveland."

You must be sure to use the same capitalization in the LoopVariable parameter and the Function parameter. Using capitalized "Counter" in the LoopVariable would not recognize the lower-cased string "counter" as the variable in the Function parameter.



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