Brian Dunning's FileMaker Custom Functions

ExitLoop ( _exitValue ; _loopLevel )

Exits loop when $i = exitValue

  Average rating: 4.4 (33 votes) Log in to vote

Arend van Asselt   Arend van Asselt - Show more from this author
Easy to Work
http://www.easytowork.nl

Share on Facebook Share on Twitter

  Sample input:
ExitLoop ( get ( FoundCount ) ; 1 )
  Sample output:
Boolean result and $i increments with loop

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

It can be used for a single loop or nested loops. It provides a unique $i value for every nested loop so you can use $i as a parameter in all your expressions in the running script.

By exit $i will be made empty so if you have a loop further on in the script you don't have to reset $i.

This example collects the ID's of a found recordset and shows $i three times in every main loop.

Loop
Exit Loop If [ ExitLoop ( get ( FoundCount ) ; 1 ) ]
Set Variable [ $list ; $list & GetNthRecord ( Evaluate(Get(LayoutTableName)&"::id") ; $i ) & ]
Loop
Exit Loop If [ ExitLoop ( 3 ; 2 )
Show Dialog [ “Hi I’m number “ & $i ]
End Loop
End Loop

 

Comments

Doug Staubach   Doug Staubach
Mar 22, 2015
These are good instructions for someone who wants to create a loop within a FileMaker Script. (However, just to be clear, the statements here will not work inside of a FileMaker Custom Function.)
 
Arend   Arend, Amsterdam
Mar 22, 2015
Hi,

Exit loop is the Custom Function and yes it will work properly!

The goal is that you can use $i as a counter several times in a script without setting $i to 0 for the next loop.
 

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.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 20 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: