The Original FileMaker Community
Business Templates - Demo Apps - Video Tutorials -Samples - Help - 46000 Member Forum

The Leading Filemaker Developer Tools

How Infinite Loops Happen In FileMaker Scripting – FileMaker Today

Get real time updates directly on you device, subscribe now.

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.


How Infinite Loops Happen In FileMaker Scripting Here you can see a script with an infinite loop and one without.


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.


How Infinite Loops Happen In FileMaker Scripting 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.


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.


How Infinite Loops Happen In FileMaker Scripting 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 This email address is being protected from spambots. You need JavaScript enabled to view it..


© 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.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More