By any chance, do you have $$i instead of $i?
Do you have any script triggers set on your layouts? (These would pop up when you step through your script in the debugger unless you have version 12 and choose to disable triggers in the debugger.)
The only scenario I can imagine for this would require a global variable ($$i instead of $i) and a script trigger such as OnLayoutEnter that is triggering a script that modifies the value of the variable. But I think you would spot that when you check your script in the debugger...
If that's not the case here, maybe you should do a Recover on your file to see if it might be damaged in some way...
Things to keep in mind about Recover:
While Recover almost always detects and fully corrects any problems with your file...
- Recover does not detect all problems
- Recover doesn't always fix all problems correctly
- Best Practice is to never put a recovered copy back into regular use or development. Instead, replace the damaged file with an undamaged back up copy if this is at all possible. You may have to save a clone of the back up copy and import all data from your recovered copy to get a working copy with the most up to date information possible.
You can use Int to clear up the problem since it will return an integer and not a fraction or decimal.
Go to Layout[ int ( $i )]
However, I vote with Phil in that you are opening layouts with triggers, not a good idea, and the prospect of having your memory gobbled up by 100 open windows is daunting... It's quite possible that Filemaker began returning the error with all of the open windows eating up the memory...
So, use a new, plain layout with no triggers for this or use Phil's other idea of using a $$_variable to tell the triggers to not work.
I name my layouts TABLE tablename and FORM tablename. My TABLE layouts never have any triggers.
Oh, yeah, I have also found making a blank layout for each table speeds up some scripts, etc.
So I could rewrite your script
Go To Layout (TABLE tablename) using all my creative energy to first put the table names into a variable and work my way from there using some of the value list functions in a loop.