7 Replies Latest reply on Mar 16, 2012 8:03 AM by pedantic

    Making the image flicker when loading a database


      Hello Everyone.


      I have a loop function in a script that looks like this:



      // The path to the JPG file that will be stored in the table

      Set Variable[$FilePath; Value:"Mac HD:ABC:DEF:GHI:MyPicture.JPG"]


      // Creates the thumbnail and sets it in the Picture field. The TrFile function is provided by Troi Automatisering's TrFile plugin.

      // This statement works, which is why I left out all the arguments.

      Set Field[DBFile::Picture; TrFile_CreateThumbnail(yada yada)]


      // A simple counter.

      Set Variable[$Counter; Value:$Counter + 1]


      // Move on to the next record

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

      End Loop

      Commit Records/Requests []



      This code works fine. But as is often the case, the customer wants more. This code saves the image to the table in the database, but the container on the screen meant to be updated with the picture does not get updated until all the images are imported. The user wants the picture to "flicker" onto the screen so that she knows that something is happening.


      I have tried placing a "Refresh Window" statement in the code after the counter increment statement, but that does not work. How can I get the new image to show on the screen immediately after import and ebfore moving on to the next record?


      Barring that, does Filemaker have a progress bar that can be thrown up when a lengthy process is executed?


      Thanks, for whatever help you can give.




        • 1. Re: Making the image flicker when loading a database



          Try putting the Commit Record step in the loop just before the Goto Record next step.  The catch to this is it will probably slow the process down considerably.




          • 2. Re: Making the image flicker when loading a database

            Thannks Bruce, but alas, that did not work.  You were right about the increase in time, though.

            • 3. Re: Making the image flicker when loading a database

              What about a:


              Pause/Resume Script [ Duration (seconds): .1 ]

              • 4. Re: Making the image flicker when loading a database



                Well here is something to try.  Put a text object on or next to the picture set to be "clear" so it doesn't show.  You will need to put a couple of space characters in it.  Give it a conditional format that sets the back ground color with the formula  mod[$counter;2] = 0


                This will change the background color on the text object everytime $counter is an even number.  If it works,  it should produce the flicker you are looking for.  Since there is no text other then the spaces in the text object,  it should be invisible when the script isn't running.


                You may have to put the refresh Window step back in,  but should be able to take out the Commit record. 


                Haven't tried this,  but it may be worth trying.




                • 5. Re: Making the image flicker when loading a database



                  As a test I tried this in a test file and found two things.


                  First it works,  but instead of the formula being mod[$counter;2] = 0  make it mod[$counter;2] = 1.  With a 0 the formula evaluates true even when the script isn't running.


                  Second,  adding the refresh window step greatly slows down the script.  As a test,  I set up loop that ran to a 1000.  The Exit Loop If statement did all the work.

                  Exit Loop if[


                  $loopcounter = $Loopcounter + 1;

                  $loopcounter > 1000 )]


                  With out the Refresh window step,  the script completed in less then a second.  Under these conditions you didn't see the flicker.  When I add the refresh window step the script ran long enough that I got bored and killed it,  but you did see the flicker.


                  So my recommendation is to come up with another way of showing that the script is running.  For instance, you could pop up a window with a message "Importing images"  To do this,  Add the following to your script.


                  Set Variable [$windowcurrent; get[windowname]

                  New Window[Message; Top: -10000]  // opens off screen so you can set the layout and size

                  Go to Layout["Message" ]

                  Move/Resize window[Current Window; Top: XXX ; Left: XXX;...]

                  # Make sure the window is to the side of the working window so it is visible when the loop is running

                  Select Window[$windowcurrent]


                  # Your current loop with out the screen flicker stuff...

                  End Loop

                  Select Window["Message"]

                  Close Window["Message"]

                  Select Window[$windowcurrent]

                  # rest of script


                  You can play with this and come up with he best position for the message window.  It will show the message,  but won't slow things down with refresh window or commit record steps.




                  • 6. Re: Making the image flicker when loading a database

                    Ray, this works.  It does have a slow-down effect (no surprise there) on the execution speed.  I have shown it to my boss and he did not like that.  See my final response to Bruce for my next step.


                    Do I need to give you credit or something for your answer? 

                    • 7. Re: Making the image flicker when loading a database

                      Bruce, thanks for the great reasearch! That was above and beyond the call. 


                      Actually, as mentioned in my response to Ray, my boss saw his solution (Pause/Resume Script...) and said that the speed was too slow, so he asked me to look for another solution as well.  It just so happened that I stumbled upon a potential alternate solution in Dr. Cologon's book, "Filemaker Pro 10 Bible" (see pp. 394-396).  In it he discusses how a progress dialog may be displayed/updated, and he also gives a goodly amount of the code needed for implementation (thanks, Dr. Cologon!).  If that method is faster, we'll be using it instead.


                      Thanks to the both of you for helping me out.


                      Take care.