Topics
All
MacOS
(Only)
Windows
(Only)
Linux
(Only, Not)
iOS
(Only, Not)
Components
Crossplatform Mac & Win
Server
Client
Old
Deprecated
Guides
Examples
Videos
New in version:
12.1
12.2
12.3
12.4
12.5
13.0
13.1
13.2
13.3
13.4
Statistic
FMM
Blog
Universal function to run a loop with evaluate.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
FM | 8.2 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
Parameter | Description | Example | Flags |
---|---|---|---|
Variable Name | The name of the variable to use. Can be with zero, one or zwei $ on the start. |
"index" | |
Start Value | The start value of the loop. | 1 | |
End Value | The end value of the loop. | 12 | |
Step Value | The number to add on each loop. Must not be zero. Can be positive to count forward or negative to count backwards. |
1 | |
Expression | The expression to evaluate. Can be in local language of FileMaker Pro or english. For Server must always be in english. |
" MBS(\"Log\"; index) " | |
ExitIfExpression | The expression to evaluate to check for exit early. Can be in local language of FileMaker Pro or english. For Server must always be in english. |
"index >= 10" | Optional |
Returns list of results or error.
Loop to place month names in a PDF table:
MBS("FM.Loop";
/* variable */ "index";
/* start */ 1;
/* end */ 12;
/* step */ 1;
/* formula */
"MBS(\"DynaPDF.Table.SetCellText\"; $table; $rowNum; index; \"center\"; \"center\"; GetValue($months; index))")
Loop with Let for multiple commands
MBS("FM.Loop";
/* variable */ "index";
/* start */ 1;
/* end */ 31;
/* step */ 1;
/* formula */
"Let([$rowNum = MBS(\"DynaPDF.Table.AddRow\"; $table);
r = MBS(\"DynaPDF.Table.SetCellText\"; $table; $rowNum; 0; \"center\"; \"center\"; index)]; r)")
Counts upward from 2 to 24:
MBS("FM.Loop";
/* variable */ "index";
/* start */ 1;
/* end */ 12;
/* step */ 1;
/* formula */
"index*2")
Example result:
2
4
6
8
10
12
14
16
18
20
22
24
Counts downwards from 1.0 to 0.0 in 11 steps:
MBS("FM.Loop";
/* variable */ "index";
/* start */ 10;
/* end */ 0;
/* step */ -1;
/* formula */
"index/10")
Example result:
1
.9
.8
.7
.6
.5
.4
.3
.2
.1
0
Inner and outer loop:
Let( [
$Expression1 = "MBS(\"FM.Loop\"; \"j\"; 1; 3; 1; $Expression2)";
$Expression2 = " $i & \" * \" & j & \" = \" & ($i * j)"
// $i in outer loop must be with $ so it's valid in the inner loop
];
MBS("FM.Loop"; "$i"; 1; 4; 1; $Expression1))
Example result:
1 * 1 = 1
1 * 2 = 2
1 * 3 = 3
2 * 1 = 2
2 * 2 = 4
2 * 3 = 6
3 * 1 = 3
3 * 2 = 6
3 * 3 = 9
4 * 1 = 4
4 * 2 = 8
4 * 3 = 12
With an exit early expression:
MBS("FM.Loop";
/* variable */ "index";
/* start */ 1;
/* end */ 12;
/* step */ 1;
/* formula */
"index*2"; // calculate this
"index >= 10") // exit if index gets big
This function checks for a license.
Created 25th March 2018, last changed 12nd June 2021