1 2 Previous Next 24 Replies Latest reply on Jun 17, 2015 10:35 AM by philmodjunk

    End Loop Problem



      End Loop Problem


      I have a basic loop script that evaluates a set of records, preforms a second script and is suppose to end and return to a layout. For some reason after the last record is found " Go to Record/Request/Page [Next; Exit after after last" the loop does not end. I used Script Debugger and found that all of the Loop script step executed fine but when End Loop was reached a occurred so I'm caught in an Infinite loop for some reason that I don't see.


        • 1. Re: End Loop Problem

          but when End Loop was reached a occurred

          What occurred?

          I suggest posting at least the loop portion of your script.

          To post a script to the forum:

          1. You can upload a screen shot of your script by using the Upload an Image controls located just below Post a New Answer.
          3. You can print a script to a PDF, open the PDF and then select and copy the script as text from the opened PDF to your clipboard for pasting here. (with this approach, you can get multiple script steps on the same line, please edit the pasted text by inserting some returns to separate those steps.)
          5. If You have FileMaker Advanced, you can generate a database design report and copy the script as text from there.
          7. If you paste a text form of the script, you can use the Script Pretty box in the Known Bugs List database to paste a version that is single spaced and indented for a more professional and easier to read format.
          • 2. Re: End Loop Problem

            Screen Shot attached!

            • 3. Re: End Loop Problem

              Were also going to need to see the script 'Update Inventory'.  I suspect it's not coming back to the first layout, at the correct record.

              • 4. Re: End Loop Problem

                That would be my guess. If so, you can add:

                Go to Layout [orginal layout]

                Immediately after the perform script step near the end of your loop.

                • 5. Re: End Loop Problem

                  @Phil..question.  In his posted script, the last 2 set field steps.  They appear to be from 2 different TO's.  Would (or could) that cause a layout change if fields come from 2 different TO's....just wondering.  Thanks

                  • 6. Re: End Loop Problem

                    Second Script attached!

                    • 7. Re: End Loop Problem

                      Follow Phil's advice, you need to change back to original layout.  Also, you're new record request is commented out, so it won't create a new record

                      Another question, and just my curiosity, why are you setting globals, based on fields, then setting fields based on globals?  Wouldn't the standard Set Variable, Set Field be a better way to go?  I know there are situations where globals are used to give the user the option of canceling a new record creation without having to do a Revert, or some other work around.

                      • 8. Re: End Loop Problem

                        @Steve, I know of no

                        way for Set Field to cause a layout change. Set field interacts with the field at the data level, not the layout level so it can't even trip a script trigger such as OnObjectModify.

                        • 9. Re: End Loop Problem

                          My experience level isn't there yet, I'm still on the up side FM scripting curve.  I know what to do from my scripting experience with MS Access 2010/VBA/SQL but my problem is quickly finding how to do it in FM.  It doesn't help when the project has a tight delivery date.

                          The manor in which I use the Global fields was taken from a solution I created years ago with FM v3.1.

                          Please don't laugh, I'm under the gun.

                          • 10. Re: End Loop Problem

                            Global fields were a standard way to do this before we had variables. They work just fine for this purpose in today's versions, but you might want to check out variables as a slightly simpler alternative with today's versions.

                            • 11. Re: End Loop Problem

                              Regarding the commented out new record request, it is there for testing, I wasn't sure if I needed it or not.

                              • 12. Re: End Loop Problem

                                Adding Go to Layout [orginal layout] Immediately after the perform script step near the end of your loop didn't work, I still have the infinite. I also noticed with Script Debugger that when "Update Inventory" script runs, I see each field in the layout is populated with the Global field data but no new record is created.

                                • 13. Re: End Loop Problem

                                  Looks like you need to add the new record request, and maybe a commit records.  Are you actually changing layouts?  If not you may be adding (when you put the new record request back in) a new record to the end of the found set and will never get to the end.  Show the tool bar and watch your found set of records, see if they increase.

                                  See if this helps.....Make a backup first.

                                  When you perform your subscript, open a new window, go to correct layout, create new record, set fields, commit record, close window.  Take out the Go to Layout (original layout) this time on the original script and see if that helps

                                  • 14. Re: End Loop Problem

                                    Yes, the "Update Inventory" script does go to a new layout "Inventory_List".  At this point in the main script, "Update Inventory" is only used to set field values in the inventory table while creating a new record.  

                                    The commented out New Record request step in "Update Inventory" script  is a question you asked about earlier and I said I didn't know if I needed it or not.  

                                    I've removed the comments text from New Record request, added Commit Record script step and now the "Update Inventory" script is working, it now creates a required new record.

                                    The issue now is the return from "Update Inventory" script.  The earlier posted suggestion was to add "Go to Layout [original layout]", this step has been added and script action does return to the original layout but it does not return to the original record.  If the script step is part of a loop, incorrect information in now being used.

                                    I guess my question is must I use set field with one of the Global fields to insure the return to the correct record? 

                                    1 2 Previous Next