From Dwayne Wright PMP, PMI-ACP, CSM
Certified FileMaker Developer
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?
GO TO NEXT RECORD LOOPS
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.
I AM COUNTING ON YOU LOOPS
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.
I AM DETECTING THAT IT IS TIME TO STOP LOOPING
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 firstname.lastname@example.org.
© 2008 - Dwayne Wright - dwaynewright.com
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.