13 Replies Latest reply on Jan 31, 2015 2:10 AM by lijnbach

    Building in a pause (milliseconds)

    lijnbach

      Title

      Building in a pause (milliseconds)

      Post

      Hello everybody,

       

      I have a loop, cycling threw records, all works fine.

       

      But, I want the loop to run just a little slower, so the user can see that something is happening. If I use “Halt - restart” script, also with a duration of 0,01 seconds, the loop becomes to slow.

       

      Ik tried it with the function “Get(CurrentTimeUTCMilliseconds)”. But I can’t get it working. I tried this:

       

      Set Variable [ $Time; Value: ( (GetAsNumber ( Get(CurrentTimeUTCMilliseconds)) ]

      Loop

          Exit Loop if [ GetAsNumber ( Get ( CurrentTimeUTCMilliseconds)) > $Time + 400

      En Loop

       

      (This is a loop within a loop)

       

      But it doesn’t seem to work,

       

      Can anyone help me out.

       

      Hans Lijnbach

        • 1. Re: Building in a pause (milliseconds)

          I use the Troi-Dialog-plugin for this:

          Dial_DelayTicks( "" ; ticks ) where 1 tick = 1/60 of a second so 0,01 second is not possible, one tick would be approx. 0,017 seconds

          but if you not allready use that plugin, it may be a bit over the top just to buy a license for this function.

          As an alternative you could use the MonkeyBread-Software MBS-plugin which has:

          MBS( "Time.Sleep"; duration ) duration is given in milliseconds

          • 2. Re: Building in a pause (milliseconds)
            philmodjunk

            Perhaps instead of a pause, you can get the result you want with just a Refresh Window step to make FileMaker pause and redraw the current screen.

            • 3. Re: Building in a pause (milliseconds)
              lijnbach

              Thanks Phil and Menno for your reply,

              I just tried Refresh window, that is a whole lot better. It would be nice to have a solution in between. No refresh window is way to fast, use "Pause - Resume" is far to slow, refresh window comes close. Just a little faster then refresh window would be nice.

              I also have a look at the MBS plugin.

              Hans Lijnbach

               

              • 4. Re: Building in a pause (milliseconds)
                philmodjunk

                Maybe if you combined your Loop with a Refresh Window just before or after the loop code....

                • 5. Re: Building in a pause (milliseconds)
                  lijnbach

                  Hai Phil,

                  I tried both, the "refresh window" within the loop works best, because the user can see what is happening. It is working well. The only thing is (not a major issue) that a little faster would be nice. In this case I have to cycle threw 850 records.

                  I also tried "refresh object" in the loop, but that doesn't seem to work. Also my script using the Get (CurrentTimeUTCMilliseconds) doesn't seem to work within the loop. Are there functions not working within a loop?

                  Hans Lijnbach

                  • 6. Re: Building in a pause (milliseconds)
                    philmodjunk

                    What I was suggesting would look something like this:

                    Loop
                        Set Variable [ $Time; Value: ( (GetAsNumber ( Get(CurrentTimeUTCMilliseconds)) ]

                        Loop

                            Exit Loop if [ GetAsNumber ( Get ( CurrentTimeUTCMilliseconds)) > $Time + 400

                        End Loop
                        Refresh Window

                     

                     

                    End Loop

                     

                    You might also try moving the refresh window up to be just above the inner loop instead of just below it.

                    • 7. Re: Building in a pause (milliseconds)
                      DavidJondreau

                      How about not using a time-based system at all but rather an "pass-based" system. Activate your Refresh Window[] step every 10 passes, rather than every pass.

                      Drop the nested loop. In your main loop do this:

                      Set Variable [$counter ; 1 + $counter ]

                      If [ $counter = 10 ]

                      Refresh Window[]

                      Set Variable ( $counter ; 0 )

                      End If

                       

                      • 8. Re: Building in a pause (milliseconds)
                        philmodjunk

                        I like David's suggestion here.

                        • 9. Re: Building in a pause (milliseconds)
                          lijnbach

                          Phil and David,

                          Thanks for your suggestion David. It is a very good suggestion.

                          But what I mend with the "Time Loop" Phil, is that it seems it isn't working at all. I replaced the time loop with your suggestion, a refresh window, and it doesn't make any difference in time when cycling threw the records. I got the feeling that the nested loop with the Get (CurrentTimeUTCMilliseconds isn't working at all.

                          But I will implement David's suggestion.

                          Both thanks for your patience and time.

                          Hans Lijnbach

                           

                           

                          • 10. Re: Building in a pause (milliseconds)
                            RickWhitelaw

                            This thread begs the question. Why would you want the user to "know something is happening"?

                            • 11. Re: Building in a pause (milliseconds)
                              philmodjunk

                              Long running scripts often leave the user time to worry that things have somehow "broken". Providing some sort of visual feedback to the user that all is working as expected helps re-assure them and if it is sufficiently informative--such as a progress bar type display, can give them a good idea if they have time to hit the head or get a fresh cup of coffee.

                              I recall back in FileMaker 3 days, setting up a layout with a massive large number in a field that represented the current found set. Since the looping script found all unprocessed records, Isolated a sub set with a common value, processed them, marked them as "processed", then looped back to find all unprocessed records, this large number started out with a value of several thousand and gradually updated to smaller and smaller values until done....

                              Recently, I saw a nice trick done where they displayed an animated gif in a web viewer while the script was running and then dismissed the small window with that web viewer when finished as a way to provide visual feedback, but without any kind of "progress" shown.

                              • 12. Re: Building in a pause (milliseconds)
                                lijnbach

                                You are exactly right Phil,

                                In my case I use a simple progress indicator, so the user is informed the software is working as expected. If I don't show anything, the user starts clicking buttons while the system is doing something else.

                                Hans Lijnbach

                                • 13. Re: Building in a pause (milliseconds)
                                  lijnbach

                                  Hai David,

                                  I set the counter on "3"

                                  Works smoothly, perfect.

                                  Hans Lijnbach