12 Replies Latest reply on Aug 18, 2016 12:07 PM by BruceRobertson

    Script Works in Debugger, Not Otherwise

    wacole1213

      This script works when I step through it with the Script Debugger.  The script's purpose is to return to a list view from an individual record view so that the active record is in the middle of the list rather than at the bottom.  The script doesn't work if it is run regularly.  I cannot figure out why there would be a difference in behavior.  Clues would be gratefully received.

      2016-08-17_13-39-44.pngbpref_goto_midpoint

       

      2016-08-17_13-31-03.png

      Oh, essentially the same script works properly and runs normally when configured for a slightly different purpose.  In this case, though, it is running against a view which is already open so no need to switch layouts.  Maybe this is a clue?

      bp_goto_midpoint

      2016-08-17_13-30-34.png2016-08-17_13-31-03.png

      Thank you very much.

        • 1. Re: Script Works in Debugger, Not Otherwise
          SteveMartino

          You're not saying how it 'doesn't work'  What does it do and what doesn't it do.  If this is all one script, then nothing really happens after Exit Script.

          Put some pauses in the script debugger.  Then instead of running the script step by step, you could run in a few lines at a time to see where it 'doesn't work' (also check the data viewer)

          • 2. Re: Script Works in Debugger, Not Otherwise
            philmodjunk

            One "gotcha" with testing scripts in the debugger is that the current layout is refreshed with every step and this isn't what happens when you run the script without the debugger. My guess is that you need a refresh window step or two in the right place, probably as part of that go to mid point script that, if I read it correctly, is trying to position the current record in the center of a list view layout.

            • 3. Re: Script Works in Debugger, Not Otherwise
              user19752

              This wouldn't be problem since you seems not using script parameter at all, but why your subscript use Get(ScriptParameter) for setting variables but not use it in Go to Record?

              • 4. Re: Script Works in Debugger, Not Otherwise
                wacole1213

                Thanks guys.  I didn't know that about the script debugger and will now keep that firmly in mind.  As to the Get(ScriptParameter) use; chalk that up to my not knowing what I was doing and just accepting the default.  i'll muck around w/both.  Again, many thanks.

                • 5. Re: Script Works in Debugger, Not Otherwise
                  BruceRobertson

                  Besides using script parameters but not really knowing why; I see that there is at least one other problem.

                   

                  I notice that you are using a lot of repeating variables.

                  I suspect you are unaware of this.

                  It indicates that you don't know your way around a Set Variable dialog.

                  Which is identical in function to many other "Set...." dialogs such as set field.

                   

                  Setting a standard variable might look like this:

                  Set Variable [ $userName; value: "wacole1213"]

                   

                  A repeating variable looks like this:

                  Set Variable [ $userName[243]; value: "wacole1213"]

                   

                  In your case you are doing:

                  Set Variable [ $rowCount[ get(scriptParameter)]; value: 36]

                   

                  The [243] part in my example is the repetition number; the particular numbered instance of this variable.

                  Almost always, you should not be doing this; the value there should be 1. The default value.

                  set variable dialog.png

                  • 6. Re: Script Works in Debugger, Not Otherwise
                    Benjamin Fehr

                    The Developers Voodoo Toolbox again:

                    commit

                    Refresh

                    Pause [0,5 seconds]

                     

                     

                    • 7. Re: Script Works in Debugger, Not Otherwise
                      BruceRobertson

                      More examples of the set variable dialog.

                       

                      set variable dialogv2.png

                      • 8. Re: Script Works in Debugger, Not Otherwise
                        wacole1213

                        Thanks for this.  i reset all of the repetition values to 1 for all the variables in the child script [bpref_goto_midpoint], including this one. As to where the Get(ScriptParameter) came from, I do not know.  I did not make that entry.  Making these changes did not seem to affect the outcome.

                        2016-08-18_10-37-07.png

                         

                        In addition I added Reset Window to the parent script

                        2016-08-18_10-32-03.png

                        I ran this with and without the two Flush options and it seemed to make no difference.  The result is that while not placing the active record in the middle [18 rows from the top] it did consistently place the active record 12 rows from the bottom.  I tried placing the Refresh Window statement at a number of locations within this script and this location was the only one that placed the active record not at the bottom of the window.  i cannot work out how the script arrives at 12-from-the-bottom for the placement of the active record.

                         

                        Changing the $rowCount value did not affect the placement of the active record, nor did changing the divisor.  Placing a Refresh Window statement in the child Script [bp_goto_midpoint] at any point did not affect the outcome one way or the other.

                         

                        I'm learning.  Thank you all.

                        • 9. Re: Script Works in Debugger, Not Otherwise
                          BruceRobertson

                          It is one thing to know how to write the variables correctly.

                          It is important to know that.

                           

                          But notice also that your script exits ABOVE the point where you set the variables; so you never ever actually use them.

                           

                          Also, you script seems to be circular; it calls itself.

                          Script bp_goto_midpoint calls script bp_goto_midpoint

                          • 10. Re: Script Works in Debugger, Not Otherwise
                            ronhofius

                            Once you sort out the proper syntax for setting variables as discussed above, what about this logic for getting to the midpoint after you're on the layout and have sorted?

                             

                             

                            Just a couple of points that don't address your question, but go to some of the issues in your sample script:

                             

                            When you call a script, you can specify an optional parameter, or some known data, to that script like so:

                             

                             

                            Then in the called script you pick it up, usually like this:

                             

                             

                            If you don't pass it and pick it uplike that using get(ScriptParameter), the called script cannot see any local variables you may have established in the calling script.  That's the significance of get(ScriptParameter).

                             

                            A similar function is get(ScriptResult), which is used to hand a value back to the calling script from the called script.  You would exit your called script like this:

                             

                            And pick it up in the calling script like this:

                             

                            • 11. Re: Script Works in Debugger, Not Otherwise
                              wacole1213

                              Sorry, missed this.  "Doesn't work": active record at bottom of page instead of at middle of page.  Thanks for the

                              • 12. Re: Script Works in Debugger, Not Otherwise
                                BruceRobertson

                                Please show a current copy of script bp_goto_midpoint.