Function overview
Prototype
While (
_iterator; _exitCondition )
Parameters
_iterator The name of the iterator variable (e.g.
_exitCondition The exit loop condition (e.g $i > 3 )
Description
Tags:
While Loop Iterator
Example usage:
Loop
Exit Loop If [ While ( "i" ; $i + 1 >= 3 ) ]
Show Custom Dialog [ Message: $i; Buttons: “OK”, “Cancel” ]
End Loop
Show Custom Dialog [ Title: "After the loop"; Message: $i; Buttons: “OK”, “Cancel” ]
This will result in showing 4 times the custom dialog box, three times inside the loop (showing 1-2-3), once outside the loop (showing empty dialogbox).
Examples
Sample input
While ( "i" ; $i + 1 >= 3 )
Sample output
Will increment $i untill $i >= 3, it will than return 1 and destroy $i
Function code
/* While ( _iterator ; _exitCondition )
by Andries Heylen, BH&A
www.bh-a.com
v.1.0 - Sep 10, 2010
- use this function in Exit Loop If [] script step
- function will create the iterator variable $ and increments it with 1
- when the exit condition is met the iterator variable is destroyed
PITFALL: when using the iterator as exit condition (for example $i > 3); you should send $i + 1 > 3. This is because the iterator is incremented only in the custom function, and you will still send the old value of the iterator when you use it in the exit condition.
*/
Evaluate ( "
Let (
$" & _iterator & " = $" & _iterator & " + 1
;
Case ( " & _exitCondition & " ; 1 & Let ( $" & _iterator & " = \"\" ; \"\" ) )
)"
)//endEvaluate
// ===================================
/*
This function is published on FileMaker Custom Functions
to check for updates and provide feedback and bug reports
please visit http://www.fmfunctions.com/fid/269
Prototype: While( _iterator; _exitCondition )
Function Author: Andries Heylen (http://www.fmfunctions.com/mid/57)
Last updated: 13 September 2010
Version: 1.2
*/
// ===================================
/* While ( _iterator ; _exitCondition )__LITBR__by Andries Heylen, BH&A__LITBR__www.bh-a.com__LITBR____LITBR__v.1.0 - Sep 10, 2010__LITBR__ - use this function in Exit Loop If [] script step__LITBR__ - function will create the iterator variable $ and increments it with 1__LITBR__ - when the exit condition is met the iterator variable is destroyed__LITBR____LITBR__PITFALL: when using the iterator as exit condition (for example $i > 3); you should send $i + 1 > 3. This is because the iterator is incremented only in the custom function, and you will still send the old value of the iterator when you use it in the exit condition.__LITBR____LITBR__*/__LITBR____LITBR__Evaluate ( "__LITBR__ Let ( __LITBR__ $" & _iterator & " = $" & _iterator & " + 1 __LITBR__ ; __LITBR__ Case ( " & _exitCondition & " ; 1 & Let ( $" & _iterator & " = \"\" ; \"\" ) )__LITBR____LITBR__ )"__LITBR__)//endEvaluate__LITBR____LITBR__// ===================================__LITBR__/*__LITBR____LITBR__ This function is published on FileMaker Custom Functions__LITBR__ to check for updates and provide feedback and bug reports__LITBR__ please visit http://www.fmfunctions.com/fid/269__LITBR____LITBR__ Prototype: While( _iterator; _exitCondition )__LITBR__ Function Author: Andries Heylen (http://www.fmfunctions.com/mid/57)__LITBR__ Last updated: 13 September 2010__LITBR__ Version: 1.2__LITBR____LITBR__*/__LITBR__// ===================================
Comments
11 September 2010
I think your documentation should mention the fact that if you want to use your iterator in the exit condition, you should add 1 to it.
While ( "i" ; $i + 1 = 3 )
11 September 2010
But would be nice if this should not be the case... However I don't see how unless sending "$i >= 3" and evaluate the calc in the custom function...
Updated the documentation!
(Edited by Andries Heylen on 11/09/10 )
13 September 2010
13 September 2010