2 Replies Latest reply on Apr 19, 2012 10:28 AM by disabled_JackRodgers

    Simple loop, but endless

    RedL

      Title

      Simple loop, but endless

      Post

      I used the below script to show all layout records for new revision export preparation.  I used it almost one year.  It ran very well for my revision data migration preparation.  But, since last week, after I make some design change, the loop becomes endless loop.  Some weird status I found.
      1. I have one window only.  But, during the loop it might create multiple windows.  Windows number can up to 100.
      2. Supposedly $i should be integer only.  But, I use debug to step script, it will be changed to 100.8 by the GoToLayout step or reset to 1.
      Set Variable [$i; Value:1]
      Loop
       Go to Layout[$i]
       Show All Records
       Set Variable [$i; Value:$i + 1]
       Exit Loop if [$i > 300]
      End Loop

        • 1. Re: Simple loop, but endless
          philmodjunk

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

          1. Recover does not detect all problems
          2. Recover doesn't always fix all problems correctly
          3. 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.
          • 2. Re: Simple loop, but endless

            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.