AnsweredAssumed Answered

Intentional Infinite Loop

Question asked by jeepboy on Nov 15, 2011
Latest reply on Nov 15, 2011 by DavidJondreau



I would love to have a little advice on this situation. I am considering employing an intentional infinite loop in a script - I need the script to search for certain records and if not found wait 5 minutes and then try again. When the records are found it performs certain actions on them. I am considering an infinite loop to accomplish this because we need to check for these records every 5 minutes 24/7.


The basic approach I'm considering is


Go To Layout (contains stop and restart buttons)


Perform find

If Get(FoundCount) > 0 perform subscript

Wait 5 minutes

End Loop


The layout that the script goes to provides buttons for a user to interrupt the process with a stop button as well as one to restart the process along with an Exit/Quit button.


My concern is that I may end up with memory problems after this script has been running for several hours, days or even weeks.


The alternative approach would be to use cron jobs in the Operating System to trigger my script to run every 5 minutes. We use this approach in some other aspects of our system but I'd prefer to not go that route and allow my users to stop and start the process from within the FileMaker system so they don't have to mess around with cron jobs themselves.


Thanks for any advice!