14 Replies Latest reply on May 19, 2017 7:27 AM by blaise

    I am stumped...keep getting "Invalid script step."

    blaise

      Running FM 12 Pro. When I try saving the script, I keep getting an "Invalid script step" with a very simple evaluation in an If script step:

       

      If [Donator List::Total Donation Limit - Donator List::Donated to Date < 5]

          End Loop

      End If

       

      "Donator List" is the current Window and both fields, "Total Donation Limit" and "Donated to Date" are number fields and it is a Boolean result.

       

      Any suggestion what I am doing wrong?

      Thanks,

       

      --Blaise

        • 1. Re: I am stumped...keep getting "Invalid script step."
          philmodjunk

          Get rid of the End Loop step

          • 2. Re: I am stumped...keep getting "Invalid script step."
            blaise

            Thanks, but that is what I want the script to do if the result is true.

             

            --Blaise

            • 3. Re: I am stumped...keep getting "Invalid script step."
              beverly

              you want

              Exit Loop

              not

              End Loop

              beverly

              • 4. Re: I am stumped...keep getting "Invalid script step."
                blaise

                Thanks Beverly, but that would take me out of the loop altogether. I just want it to do the loop again with the next record. (I have a Go to Next record later on.)

                 

                But, that got me thinking. So I reversed the logical operator to ≥ and then moved the End If to enclose the steps to happen when the result is true. If its false, it does the loop again.

                 

                That did it. Thanks all.

                 

                --Blaise

                • 5. Re: I am stumped...keep getting "Invalid script step."
                  philmodjunk

                  You need

                   

                  Exit Loop If [ Donator List::Total Donation Limit - Donator List::Donated to Fate < 5 ]

                   

                  End Loop is just a bookend used to enclose a set script steps that will be executed over and over in a loop. It doesn't exit the loop, it sends control back to the first step after Loop. For every loop there must be one and only one End Loop just as there must be one and only one End If for every If.

                  • 6. Re: I am stumped...keep getting "Invalid script step."
                    beverly

                    without your full script posted, it was difficult to assess the corrections! the Exit Loop was why you got the error.

                    good that you got it working. can you post the correct answer (your script) so others may learn and then mark that as "Correct Answer"?

                    beverly

                    • 7. Re: I am stumped...keep getting "Invalid script step."
                      blaise

                      Thank you,

                       

                      That would indeed be a more elegant solution. I will try that. But that is contrary to what the description of the Exit Loop If step says.

                       

                      "Description

                      If the calculation is True (not zero), the script continues with the script step that follows the End Loop script step.

                      If the calculation if False (zero), the loop is not exited and the script continues with the script step that follows the Exit Loop If script step."

                       

                      This is an inner nested loop so if the result is true it would not go to the next record and re-evaluate, it would go to the outer loop, which is not what I want. But I will still try it.

                       

                      Thanks,

                      --Blaise

                      • 8. Re: I am stumped...keep getting "Invalid script step."
                        beverly

                        Post your full script?

                        beverly

                        • 9. Re: I am stumped...keep getting "Invalid script step."
                          blaise

                          Beverly,

                           

                          How? I can't cut and paste.

                           

                          I wasn't getting the error message with the Exit Loop If step. I was getting it with the End Loop statement as explained by philmodjunk above and shown in the initial post.

                           

                          It probably won't be the whole script. It is part of something I am getting patented.

                           

                          Just as I said above, the Exit Loop If script step didn't work. It prematurely threw me out of the inner loop into the outer loop.

                           

                          Again, how to post a script without retyping it?

                           

                          --Blaise

                          • 10. Re: I am stumped...keep getting "Invalid script step."
                            philmodjunk

                            I highly doubt that you can patent a FileMaker script--too hard to show that it's something unique, but that's between you and a patent lawyer.

                             

                            You can post a screen shot of the script taken in the scripts workspace.

                             

                            You can print the script to a PDF and copy/paste the script as text from the PDF

                             

                            You can generate an HTML type DDR from FileMaker advanced and copy/paste the script as text from the DDR.

                             

                            If you don't have FileMaker Advanced, you need it.

                            • 11. Re: I am stumped...keep getting "Invalid script step."
                              beverly

                              I apologize for confusing you. We may answer without getting the other's replies.

                               

                              Phil said to delete the End Loop, which I did not see.

                              I said to change to Exit (fixed the error but stopped when you did not want to).

                               

                              You may print to PDF the script and post in your reply. Use the Advanced Editor to attach a PDF.

                               

                              I will bow out so you get one answer...

                              beverly

                              • 12. Re: I am stumped...keep getting "Invalid script step."
                                blaise

                                Thanks,

                                 

                                Yeah, I won't be patenting the actual script. I am making a prototype of a system that will behave according to the idea that I am patenting. It is just for demonstration. The actual incarnation may not even be in FM. But someone may get enough of the idea from the full script to scoop me. Thanks for the advise and suggestion.

                                • 13. Re: I am stumped...keep getting "Invalid script step."
                                  philmodjunk

                                  I think that you've actually fixed the problem and need not post again unless you want to.

                                   

                                  I think that you just wanted the loop to continue while skipping certain steps within the loop if a condition was met and what you describe would then be exactly what you need.

                                   

                                  For future reference, sometimes people take their example or description of an issue and modify terms used to make them generic. One poster years ago, for example, referred to "radios" in his posts while privately explaining to me that they were actually firearms issued to security personnel.

                                  • 14. Re: I am stumped...keep getting "Invalid script step."
                                    blaise

                                    This script is valid but exits the inner loop prematurely.

                                     

                                    Loop

                                        Select Window [ Name: "Donator List"; Current file ]
                                       
                                    Perform Find [ Specified Find Requests: Find Records; Criteria: Donator List::Tier: “$TierNo” ] [ Restore ]

                                        Set Variable [ $NoInTier; Value:Get ( FoundCount ) ]

                                        Loop

                                                             #This step checks the Donators donation limit.

                                                 Exit Loop If [ Donator List::Total Donation Limit - Donator List::Donated to Date < 5 ]

                                                  Set Variable [ $DonatorName; Value:Donator List::Name ]

                                                  Show Custom Dialog ...

                                                             #If choice is 1 then do these things...     

                                                  If [ Get ( LastMessageChoice ) = 1 ]

                                                             #These add the donation to the donation list.

                                                        Select Window ...

                                                        New Record/Request

                                                        Set Field ....

                                                        Set Field ...

                                                             #These update the project list.

                                                        Select Window ...

                                                        Perform Find ....

                                                        Set Field ....
                                                        Set Field ...

                                                        Exit Loop If [ Project List::Project Status 5 ]

                                                  End If

                                              Select Window [ Name: "Donator List"; Current file ]

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

                                        End Loop
                                        Select Window
                                    [ Name: "Project List"; Current file ] #The next line sets the lowest gift level.
                                        Exit Loop If [ Project List::Project Status 5 ]
                                        Set Variable [ $TierNo; Value:$TierNo + 1 ]
                                        Exit Loop If [ $TierNo >3 ]

                                    End Loop

                                     

                                     

                                     

                                    This is the correct, working script. (Steps in red replaced the Exit Loop If step.)

                                     

                                    Loop

                                        Select Window [ Name: "Donator List"; Current file ]
                                       
                                    Perform Find [ Specified Find Requests: Find Records; Criteria: Donator List::Tier: “$TierNo” ] [ Restore ]

                                        Set Variable [ $NoInTier; Value:Get ( FoundCount ) ]

                                        Loop

                                                             #This step checks the Donators donation limit.

                                            If [ Donator List::Total Donation Limit - Donator List::Donated to Date 5 ]

                                                  Set Variable [ $DonatorName; Value:Donator List::Name ]

                                                  Show Custom Dialog ...

                                                             #If choice is 1 then do these things...

                                                  If [ Get ( LastMessageChoice ) = 1 ]

                                                             #These add the donation to the donation list.

                                                        Select Window ...

                                                        New Record/Request

                                                        Set Field ....

                                                        Set Field ...

                                                             #These update the project list.

                                                        Select Window ...

                                                        Perform Find ....

                                                        Set Field ....
                                                        Set Field ...

                                                        Exit Loop If [ Project List::Project Status 5 ]

                                                  End If

                                              End If

                                              Select Window [ Name: "Donator List"; Current file ]

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

                                        End Loop
                                        Select Window
                                    [ Name: "Project List"; Current file ] #The next line sets the lowest gift level.
                                        Exit Loop If [ Project List::Project Status 5 ]
                                        Set Variable [ $TierNo; Value:$TierNo + 1 ]
                                        Exit Loop If [ $TierNo >3 ]

                                    End Loop

                                     

                                    Thanks everyone. I've learned something.

                                    --Blaise