Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 3446 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted (edited)

I have a pretty large script with a few loops.  All loops have a go to record next exit after last and somehow it is not and is going into an infinite loop.  Is there a limitation to this I am unaware of?

I do have steps after all exit after last commands.  Is this a bug because everything I read said it will end the loop?  Thanks for anyone that can help.

Oh FM13

 

 

Edited by Trinity32244
Posted

you should step through the script with the script debugger and data viewer on.

If you don't have advanced then post your script or file.

or thoroughly analyze the logic by hand. Youve probably not nested the loops correctly but i can only guess.

Posted

Thanks for responding so quickly.  No if statements at all.  I will try to post the file.  Not sure about the nesting but I do have loops inside of loops but every loop has a exit after last.  I am sure I can create some other variables to accomplish instead of using the exit after last but for me it was a complicated script and am behind schedule so pretty frustrated this is not working how it is suppose to (or how I thought it did).  

 

Also is there a way to copy the text so I don't have to post the whole entire file? 

Posted

is there a way to copy the text so I don't have to post the whole entire file? 

​You could print your script to PDF and copy from there (easy on a Mac, don't know about Windows). However, rather than dumping the entire script here, I suggest you simplify it first. There is a very good chance you will spot the problem yourself in the process.

Posted

Here is the script.  Do pay any mind to the comments.  The script has been hacked at and they don't apply anymore because I rewrote the entire script.  Thanks for any advice.  

script1.jpg

script2.jpg

script3.jpg

script1.jpg

Posted (edited)

Shouldn't your first Go To Related Records go OUTSIDE the first LOOP - other wise you keep finding the same set of records:

stuff
stuff
GTRR
Loop
     stuff
     stuff
     GTRR
     Loop
         stuff
          stuff
          GoToRecord[Next, exit after last]
     End Loop
    GoToRecord[Next, exit after last]
​End Loop

Maybe?   ;o)

Don Wieland
DW Data Concepts

Edited by dwdata
  • Like 1
Posted

Do pay any mind to the comments.  The script has been hacked at and they don't apply anymore because I rewrote the entire script.

​Then you should delete them; outdated/wrong comments are a hindrance, not a help.

Once done, I suggest you go over the script and add new comments that help you understand the script flow, and by extension, find the error. (We're not privy to your database, but I still suspect that the script could be simplified …)

These accurate comments will also give others clues as to what's going on in that script, in case you need help with it in the future.

Posted

Adding to Don Wieland's excellent observation, note that your script really SHOULD include some if statements.

You should test for the existence of related records; and only GTRR if they exist.

  • Like 1
Posted

Hey Don maybe I do not understand fully the way filemaker handles scripting.  In your example

stuff
stuff
GTRR //Table 1
Loop
     stuff
     stuff
     GTRR //Table 2
     Loop
         stuff
          stuff
          GoToRecord[Next, exit after last]
     End Loop
    GoToRecord[Next, exit after last] // ???? How would the script not still be at table 2
​End Loop

 

Looking at your example and the other comments I did find a way to simplify my code quite a bit.  Please see comments in red and if I am incorrect let me know.  Thanks

Posted

I can fix my issue I think by just getting record count and create an indexing variable that escapes on last record but would like to know if this is not needed in the above example.  Thanks again

Posted (edited)

You really should comment your code:

stuff
GTRR // Table 1
# Go to record [ first ]
Loop // through table 1
  
stuff
  stuff
  GTRR // table 2
  
# Go to record [ first ]
  Loop // through table 2
    stuff
    Go to Record [ next; exit after last]
  End Loop // table 2
  Go to Layout [ of table 1 !! ] // back into table 1 loop
  Go to Record [ next; exit after last] // Here, you don't want to be at table 2!!
​End Loop // table 1

Note the Go to Layout[] that brings you back to table 1.

Edited by eos
Posted

Not sure if you solved this already. I agree with EOS in using the Go To Layout[] to return back to the ordinal layout after looping the related records.

Another option is to process records in a NEW WINDOW (off screen) then CLOSE it afterwards.

Attached is a sample file. If it fits the bill, do us a favor and post what you did in your script so it is available to the public for learning purposes.

Hope this helps and good luck!

script_loop.fmp12

Posted

I appreciate all of the help.  I was able to condense my code quite a bit after reading everyones comments.  I did structure my script more like DWData suggested.  I never did find where the infinite loop was coming from but after I changed it did solve most of the issues.  One major thing I was missing is that the layout chosen in the GTRR does matter.  I figure the layout was more of a form and what ever T.O. I am looking at would just decide which records to show.  It still doesn't make a lot of since to me that I would pick a related record from a table and the layout definition would matter.  I usually do everything with portals and the GTRR will just run through the portals instead of navigating away like this.  Also seems to be much cleaner, less clunky, and much much faster when I use the GTRR with portals. 

This topic is 3446 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.