11 Replies Latest reply on Jun 29, 2017 11:32 AM by BruceRobertson

    Exit Loop If

    BigEddie

      Hi People

       

      I have a test script that I am using to deal with an issue but getting some very odd results. I have a nested loop and the inner loop exits if a variable is the same as another.  It works the first time but when the second loop starts, it ignores the Exit If - I know the variables are right because I can see them in the data viewer and these variables respond correctly to the set field above.  Any ideas?  File with script attached.

       

      Many thanks

       

      Richard

        • 1. Re: Exit Loop If
          siplus

          this is smelly:

           

          Case (  $mainloop = "2" ; "B" ;

          $mainloop = "2" ; "C" ;

          $mainloop = "3" ; "D" ;

          $mainloop = "4" ; "E" ;

          $mainloop = "5" ; "F" ;

          $mainloop = "6" ; "G" ;

          $mainloop = "7" ; "I" ;

          $mainloop = "8" ; "J" ;

           

          "")

           

          and tbh it can be abbreviated to something like Middle("ABCDEFGHIJ"; $mainloop; 1)

           

          now, to your question,  exiting the loop.

           

          You exit the loop if $mainloop = $$subcount. $MainLoop starts with zero and increments, but we know nothing about $$subcount, which gets the value via a relationship and might as well get a "" so the loop will never exit. Are you sure that Qt is always > 0 ?

          • 2. Re: Exit Loop If
            siplus

            this is the whole script for TL; DR people

             

            Enter Find Mode [ Pause: Off ]

            Set Field [ test::OrderNumber ; "2001" ]

            Perform Find []

            Go to Record/Request/Page [ First ]

            Loop

              Set Variable [ $details ; Value: test::Details ]

              Set Variable [ $$subcount ; Value: test::Qty ]

              Set Variable [ $PanelID ; Value: test::ID ]

              Set Variable [ $mainloop ; Value: 0 ]

              Go to Layout [ “Other Table” (Other Table) ; Animation: Slide in from Left ]

              Loop

              New Record/Request

              Set Variable [ $mainloop ; Value: $mainloop + 1 ]

              Set Field [ Other Table::ID ; $PanelID ]

              Set Field [ Other Table::Details ; $details ]

              Set Field [ Other Table::OrderNumber ; "2001" ]

              #

              If [ $mainloop = 1 ]

              Set Field [ Other Table::Qty ; 1 ]

              Else

              Set Field [ Other Table::Qty ; Case (  $mainloop = "2" ; "B" ; $mainloop = "2" ; "C" ; $mainloop = "3" ; "D" ; $mainloop = "4" ; "E" ; $mainloop = "5" ; "F" ; $mainloop = "6" ; "G" ; $mainloop = "7" ; "I" ; $mainloop = "8" ; "J" ; "") ]

              End If

              Exit Loop If [ $mainloop = $$subcount ]

              End Loop

              Go to Layout [ “test” (test) ; Animation: None ]

              Go to Record/Request/Page [ Next ; Exit after last: On ]

            End Loop

            #

            #

            #

            #

            #

            • 3. Re: Exit Loop If
              schamblee

              I didn't see a loop script in your sample file.   I seen a login with a password.   If that is your real password on any site then I would changed it.  Hackers will use your email address, the  user name  and  that password and test with 1000's of different websites.  

              • 4. Re: Exit Loop If
                BigEddie

                The $$ is a mistake, I was experimenting, it's just supposed to be  '$mainloop = $subcount' the Qty is always 1 or more.

                • 5. Re: Exit Loop If
                  BruceRobertson

                  Try again. You appear to be looking at the wrong file.

                  • 6. Re: Exit Loop If
                    schamblee

                    Well, whoever file it is does not need to include user names and passwords. 

                    • 7. Re: Exit Loop If
                      siplus

                      no user names no passwords, schamblee... file opens just flawlessly, Bruce is right, you are clicking on weird stuff.

                      • 8. Re: Exit Loop If
                        ChrisJohnston

                        Change your Qty to type number instead of text and tell me what you get?

                         

                        2 of 2 people found this helpful
                        • 9. Re: Exit Loop If
                          BigEddie

                          That was it, thank you very much

                          • 10. Re: Exit Loop If
                            schamblee

                            I click the above link, download a  zip file, with a file named test.fmp12. 

                            • 11. Re: Exit Loop If
                              BruceRobertson

                              Nope. The screenshot you show is not from this file.

                              There are a LOT of files named TEST that people have submitted in this forum and others.

                              This file has six records, for one thing.

                               

                              Screen Shot 2017-06-29 at 11.31.25 AM.png