An OnTimer script running every second is not a good idea. There's probably a better way to handle the issues your trying to solve.
I would be happy to explore other options for this script.
It is for printing labels from iPad without and print dialog and without the page formatting issues from the iPad. Printing from FMP has zero issues with page format. There seems to be no way to print from the iPad without dialog. I have a guy who did an iOS app that runs every second on the iPad that does the same thing to avoid the dialog, but the page format issue persists and I have not got it working just right yet.
The labels need to be printed on demand from a button press on iPad. With the OnTimer script it is running smoothly, but seems to be a waste of a license and machine, but it is a needed functionality.
https://fmdev.filemaker.com/message/156780#156780 has detils on how the script works. It loops looking for a flag and prints the flagged records.
I did think about this, but I could not come up with another way to do it.