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
Michael Kupietz - Show more from this author
Michael Kupietz FileMaker Consulting https://michaelkupietz.com |
"counter" ;
3 ;
6 ;
"counter & \"^2+1 = \" & counter * counter + 1 & \" ... \" "
)
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"
then
mkForDo (
"COUNTER" ;
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.
Comments
Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.