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
http://www.kupietz.com

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"

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

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.

Under construction. Email me your wish list for improvements.