12 Replies Latest reply on Jan 17, 2017 3:00 PM by lindseym

    Script - Same steps in different scripts do not perform the same

    lindseym

      I have a script that stopped working.

       

      I am not sure what I changed to cause the problem, but what I ended up doing was taking the portion of the original script that wasn't working and make a new one with just that script step isolated and it worked just fine.

       

      What's the best way to troubleshoot this?

       

      This is the one that doesn't work. (its the last part starting at step 16)

      Screen Shot 2017-01-16 at 9.58.19 AM.png

      When I copied just the last steps, it performs as expected.

      Screen Shot 2017-01-16 at 9.57.49 AM.png

       

      Thanks,

       

      -L

       

      edited to add this video for clarification from Bruce.

        • 1. Re: Script - Same steps in different scripts do not perform the same
          BruceRobertson

          These script steps make no sense; and there is no way to troubleshoot them.

           

          Enter Find Mode [ restore ]

          Perform Find [ restore]

           

          The Perform Find [ restore ] cancels anything that was set up in Enter Find Mode [ restore ]

           

          Using Restore in these script steps means that nobody can read them and nobody can know what they do.

          Use the following procedure for Finds

          Enter Find Mode [ ]

          Set field [ someField; someValue]

          Set field [ anotherField; otherValue]

          etc

          Perform Find [ ]

          1 of 1 people found this helpful
          • 2. Re: Script - Same steps in different scripts do not perform the same
            lindseym

            BruceRobertson

             

            I didn't realize that you could just use "Perform Find" and not have to tell it to navigate somewhere specific.

             

            I can remove the Enter Find Mode from the script no problem.

             

            When I use your procedure for finds, I am not sure how to enter "someValue"

             

            FMP seems to prompt me to select a field and then wants me to carry on with my day. I've added a video  to the original post to show you what I see.

            • 3. Re: Script - Same steps in different scripts do not perform the same
              keywords

              lindseym wrote:

               

              I have a script that stopped working.

               

              I am not sure what I changed to cause the problem, but what I ended up doing was taking the portion of the original script that wasn't working and make a new one with just that script step isolated and it worked just fine.

               

              What's the best way to troubleshoot this?

               

              One thing you could do to help yourself troubleshoot, and help folks on this forum to help you, is be specific. Statements like "the script stopped working" is useless. What was the outcome of the script (1) that you expected, and (2) that you got? This might be as simple as—I expected to get a found set of 30 records (what you get if you perform the Find manually, say) but I ended up with a set of 44. Or—I expected the found set would be sorted by date order but instead they are sorted alphabetically.

              You will note that so far the only response so far addresses a different part of your script than the bit you say "worked fine" in isolation. While Bruce has pointed you to part of your script that needs to be addressed it is a bit of a shot in the dark as to whether that has anything to do with whatever problem you are experiencing, because your question is so vague.

              Unfortunately a lot of people post vague questions on this forum and sometimes it amazes me that anyone responds.

              1 of 1 people found this helpful
              • 4. Re: Script - Same steps in different scripts do not perform the same
                BruceRobertson

                Your movie shows clearly that the Set Field dialog present TWO Specify buttons.

                One for Target field.

                One for Calculated result.

                Your movie shows you clearly ignoring this second button.

                 

                The Set Field script step is one you will use quite a lot when building scripts.

                So it will be worthwhile to make sure you gain a really solid understanding of how to use it.

                1 of 1 people found this helpful
                • 5. Re: Script - Same steps in different scripts do not perform the same
                  BruceRobertson

                  "I didn't realize that you could just use Perform Find and not have to tell it to navigate somewhere specific."

                   

                  Where did that come from?

                  Context is almost always important in Filemaker and you do want to be sure you are on the correct layout.

                   

                  • 6. Re: Script - Same steps in different scripts do not perform the same
                    lindseym

                    I went back and watched the video.

                     

                    Screen Shot 2017-01-16 at 4.24.43 PM.png

                     

                    I didn't realize that the calculated result is what you referred to as "someValue". I thought it would allow me to  click after the the semi colon. I was confused how this part worked.

                     

                    Mostly because I think I was anticipating something like what you get when you use the perform find option:

                     

                    Screen Shot 2017-01-16 at 4.26.42 PM.png

                     

                    Thanks for clearing up some of the jargon.

                    • 7. Re: Script - Same steps in different scripts do not perform the same
                      lindseym

                      BruceRobertson you said:

                       

                      These script steps make no sense; and there is no way to troubleshoot them.

                       

                      Enter Find Mode [ restore ]

                      Perform Find [ restore]

                       

                      The Perform Find [ restore ] cancels anything that was set up in Enter Find Mode [ restore ]

                       

                       

                       

                      I thought that I had to tell the script to "go to the find mod and then perform this search"

                       

                      I removed the unneeded "Enter Find Mode [restore]

                      • 8. Re: Script - Same steps in different scripts do not perform the same
                        BruceRobertson

                        It will still be important to learn to use Set Field.

                        Both within a Find script; and for other purposes.

                        i still suggest you do that within the script you are testing.

                        Enter Find mode[ ]

                        Set Field [ target field; targetValue ]

                        more fields if necessary...

                        Perform Find [ ] (No restore)

                         

                        Further; you need to tell US what is happening/not happening

                        But it is important to include this kind of testing in your script.

                        Example

                        If [ get( found count) = 0 ]

                        # now what?

                        Else

                        # do other script stuff

                        End if

                        1 of 1 people found this helpful
                        • 9. Re: Script - Same steps in different scripts do not perform the same
                          BruceRobertson

                          If you had done those things in the original script, we would not be six hours into a troubleshouting session yet still with absolutely no description of the problem.

                          • 10. Re: Script - Same steps in different scripts do not perform the same
                            lindseym

                            I will take your advice and learn to use set field.

                             

                            In trying to figure out what went wrong, based on your advice I did see some other unnecessary script commands that I have removed.

                            • 11. Re: Script - Same steps in different scripts do not perform the same
                              BruceRobertson

                              OK.

                              Is there still a problem?

                              If there is still a problem - what IS the problem?

                              (See questions by keywords)

                              • 12. Re: Script - Same steps in different scripts do not perform the same
                                lindseym

                                The problem.

                                 

                                When I pushed a button to trigger a script, it would perform all the script steps without issue until it  was told to save the layout as a PDF.

                                 

                                I separated the script to perform the save as PDF function and it worked fine. So I was confused why it wasn't working. I could get it to run when I pressed play in the script workspace.

                                 

                                I can see how "It stopped working" was not going to help me..... or help anyone understand what was going on.

                                 

                                 

                                 

                                 

                                What I ended up doing to resolve the issue, was  changing each script  step to use a prompt dialog - instead of bypassing and automating the whole process. I thought this would allow me to see where things were getting caught up. I realized that the script was getting hung up only when I pushed the button I created to run the script on the layout page.

                                 

                                 

                                After I had messed around a little - removing unnecessary script commands and testing other scripts I started getting an error about an unrelated table, when I selected the button to run the script.

                                 

                                 

                                It turn out (some how because I don't remember editing any buttons for a few weeks) that the action for the button had been changed to another very similar script. That performs the same 15 or so steps before going in another direction.

                                 

                                I realize now I could make a script for the first 15 steps and use them within other scripts with the same first 15 steps.

                                 

                                So... I did a poor job of explaining my issue.. but in the end, I got it

                                 

                                I'll be more explicit in the future and realize this will help me solve issues quicker -- and not drive people who are trying to help me bonkers.

                                 

                                -L