How Infinite Loops Happen In FileMaker Scripting

From Dwayne Wright PMP, PMI-ACP, CSM
Certified FileMaker Developer

TWITTER: dwaynewright
YOUTUBE: FileMakerThoughts

Scripts with loops are one of the main ways to have FileMaker perform tedious tasks on a set of records. When a script enters into a loop routine and there isn’t any programmed option in which the script can exit the loop.

So how does a script with an infinite loop happen? What does a script with an infinite loop look like?

A very common script loop is the one that goes from one record to the next in the found set, performing an action on each record it comes across. In a case like this, the last record in the found set needs a flag to exit the loop. If it doesn’t, the script will loop continually on the last record, performing the same action on that record again and again. In a case such as this, the normal flag to exit a loop comes from the script step of Go To Record [Next] in which an option of “Exit After Last” needs to be checked.

Here you can see a script with an infinite loop and one without.

Another typical loop script is to have FileMaker perform an internal count and then exit the loop when the count hits a determined level. For example, you can have an Exit Loop If step activate when the counter reaches a predetermined number.

Here you can see a snapshot from an example file and the script is uses. Here a user manually enters the number of loops to perform and the script exits when its count equals that value.

The Get family of function capture what is going on in FileMaker or in the computer system running FileMaker at a particular point in time. This information can be used anywhere that you might encounter the calculation dialog box. They can be critical in the use in Exit Loop script step because they can be used in a calculation to detect when it is time to quit.

This isn’t how you would do it in the “real world” but you can see that this exit script would work. It uses Get functions to detect how many records are in the found set and what the current record is. When these two values are equal, the script knows that it is time to exit the loop.
More info about the author and FileMaker in general, contact me at

© 2008 - Dwayne Wright -

The material on this document is offered AS IS. There is NO REPRESENTATION OR WARRANTY, expressed or implied, nor does any other contributor to this document. WARRANTIES OF MERCHANT ABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY DISCLAIMED. Consequential and incidental damages are expressly excluded. FileMaker Pro is the registered trademark of FileMaker Inc.