5 Replies Latest reply on Feb 3, 2016 7:13 AM by Steve Wright

    Random background pictures

    arminius

      Hello,

       

      i want for my log-in area a random picture function. How can i create this?

       

      f.e. each a user open the app a random picture will be selected by the system. This random picture is stored with 10 other pictures.

      It must be also a time period included that will switch to an other random picture after 30 seconds.

       

      Is it also be possible to checck if a user make to interaction with the app, that the system jumps back to the locking-area?

       

      I work on filemaker 14 on mac.

      This solution must work in an app and also on desk.

       

      Thanks

       

      Armin

        • 1. Re: Random background pictures
          onefish

          Hmm, interesting concept Armin. I believe it is possible with a bit of careful planning and limitations. You would need to right a script to set the background image which should be easy enough. Put it in a loop that pauses for 30 seconds each loop cycle.

           

          I think that you would have to name your image files something like 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. Then use the following calculation to randomly determine what image to set: "YourImagesFilePath"&Int(Mod(Random, 1) /.1)&".jpg"  This would be inside the loop too obviously.

           

          Now for the tricky part, keeping the darn thing running. If all the scripts in your database are initiated by buttons you could accomplish this pretty easy by having every button set to halt existing scripts and have every script run your background script at the end. This would meen that the 30 second timeframe for changes might be only 1 second or up to 59 seconds depending on where the pause step sits in the loop. If that's not acceptable then you could store the last image change time in a global variable from inside the loop and use it to specify the pause time of your script.

           

          Now if you trigger scripts from other means there isn't any easy means that I'm aware of to halt the existing script. You can have it do so via a hidden button though but the button has to be on every layout.

           

          Anyhow, it was thought provoking, good luck!

          • 2. Re: Random background pictures
            Steve Wright

            You could use

             

            InstallOnTimerScript[ "ChangeImageScript" ; Interval 30 ]

             

            When interaction occurs, use InstallOnTimerScript []  to prevent it running again.

            This could be done by layout triggers such as 'OnLayoutKeystroke' (Edit: Mind you, then you would need to start it again somehow)

             

            Perhaps call InstallOnTimerScript[]  only within scripts that leave the 'login-in-area' or via a layout trigger "OnLayoutExit"

            • 3. Re: Random background pictures
              Steve Wright

              Just to clean my last response up, because of additional considerations and if you get it by Email, you may not get the edits I added above..

               

              Set a layout script trigger:  OnLayoutEnter.

              Within the script you call add a step to: InstallOnTimerScript[ "ChangeImageScript" ; Interval: 30]

               

              This will run once every 30 seconds, so won't tie up FM with a looping script.

               

              Next, add a layout script trigger: OnLayoutExit.

              Within the script you call add a step to: InstallOnTimerScript[ ]    (leaving values empty)


              This will stop the ontimer script running.

              • 4. Re: Random background pictures
                onefish

                Steve, that is much cleaner. I've never used InstallOnTimer before but it kind of looks like it's made for what Armin is trying to do. So long as it works on Go too.

                • 5. Re: Random background pictures
                  Steve Wright

                  onefish wrote:

                   

                  Steve, that is much cleaner. I've never used InstallOnTimer before but it kind of looks like it's made for what Armin is trying to do. So long as it works on Go too.

                   

                  InstallOnTimerScript  is supported for Pro, Go, WebDirect & Runtime, so should be fine.  Install OnTimer Script