8 Replies Latest reply on Aug 13, 2010 7:53 AM by FentonJones

    When is Refresh Window needed?

    DLW-BPEX

      Title

      When is Refresh Window needed?

      Post

      I have a Windows runtime solution that exhibits the infamous, spastic flickering/flashing of the screen. About a half-dozen scripts generate charts via Web viewer calculations, and a couple of the scripts call others that apply to different tabs on the same layout.

       

      Since the solution is quite small and uses very little processing power, we had included Refresh Window steps near the end of each just to be "safe". Finally realized, though, that removing Refresh Window reduces the flicker dramatically -- probably because of the nested scripts performing that step multiple times.

       

      My question: How to decide when Refresh Window is truly needed? Does not Commit Records accomplish basically the same thing?

      Thank you for any help.

        • 1. Re: When is Refresh Window needed?
          TKnTexas
             I have a script going through record by record of a found set, evaluating a condition and doing an action (which is a simple Set Field).  I used a REFRESH WINDOW at the end of the script because I used a FREE WINDOW script near the top.  I was blown away on how fast the script ran.  It is a XP runtime 10.3. 
          • 2. Re: When is Refresh Window needed?
            DLW-BPEX
              

            Thank you. Yes, that is consistent with this insight from The Missing Manual:

            "Refresh Window forces FM to update what's inside the window when it normally wouldn't... because you previously ran the Freeze Window step, or because FM's simply being conservative."

            I guess my basic question still is, in what other circumstances would using Refresh Window be prudent? And is it unnecessary if Commit Records is used ultimately?

            Thank you.

            David 

            • 3. Re: When is Refresh Window needed?
              philmodjunk
                 I generally avoid using refresh window until I encounter a specific situation where the window is not updating the way I need it to.
              • 4. Re: When is Refresh Window needed?
                DLW-BPEX
                  

                Thank you, PhilModJunk. That is reassuring. I do not see (nor expect to, in the case of this solution) any reason why all would not be updated without Refresh Window. I guess "playing it safe" isn't always.

                David 

                • 5. Re: When is Refresh Window needed?
                  philmodjunk
                     And in this case it can slow down the execution of your script.
                  • 6. Re: When is Refresh Window needed?
                    FentonJones
                      

                    Refresh Window [ flush cached join results ] should only be used when necessary; which is when calculations do not recalculate on the screen. It is not always a matter of safety, since the values have recalculated already, and would be correct if you call them via script, etc.; they just are not being "refreshed" on the visual window. But if someone is relying on readying the correct value in order to make a business decision, then yeah, it would be better to show the new correct value. 

                     

                    It is usually because there are relationships to other tables involved, with further calculations using them, etc.. I cannot really explain it very well. But whenever it happens I often think, "I didn't think that was going to recalculate." In most cases like this Commit Record (while almost always my 1st attempt to make it happen) do not make it happen. 

                     

                    I would love to see an example file with a series of calculations showing which kinds require Refresh Window, and which do not. On a Mac it is not a big problem, as a well-written script using Refresh Window is hardly noticeable. It is more of a problem on Windows, where often the screen draws, then redraws with the Refresh step. A poorly written script can do that on either platform. If I have to use Refresh, then I'll use Freeze Window near the top of the script, and Refresh Window as the last step.

                    • 7. Re: When is Refresh Window needed?
                      Æthernaut

                      I see how to setup a script and how to trigger it with a keyboard shortcut, but is there a way to call a script as a function of a value changing within a field?

                      • 8. Re: When is Refresh Window needed?
                        FentonJones

                        This seems to be a different topic than "Refresh Window". But maybe not, as I often have a script with:

                        Commit Record
                        Refresh Window [ flush cached join results ]

                        Which I call via a Script Trigger, attached to the field. It is needed when changing a value in a field should cause calculations to re-evaluate but do not. Which can be the case if the changed field, or the calculation, is not local to the table of the current layout, etc.. That is the answer to your question. Script Triggers require FileMaker 10+; especially such ones as OnObjectModify, OnObjectSave, OnObjectExit.