3 Replies Latest reply on Mar 3, 2017 3:11 AM by fmpdude

    OnTimer continues when layout is closed.  Adding backing up to the script.

    AitchB

      Good morning,

       

      I have a FM DB that only my wife and I use. It is used either on our iMac or our Macbook.

      The DB is saved in iCloud so it is available on both but I need to close one (Exit Application) before opening on the other so that they remain in sync. Any changes are reflected on the iCloud version only when the DB exits.

       

      Using Filemaker server is too expensive.

       

      The DB opens on a layout « Home Page ». We navigate to other layouts from there (New client, new booking etc.)

       

      I used a script trigger OnTimer on the « Home Page » to run a script « Exit App » after a set time. So if we forget to close the DB…

       

      However I thought I read that the OnTimer script would stop when the layout was closed but when I open another layout (New client etc) it continues it’s countdown. I also considered putting another OnTimer script trigger on all the other layouts « after nn seconds open layout « Home Page » which would trigger the exit app close script but if that is counting down it won’t work!

       

      As weIl I wanted to do a backup when the DB is closed. Looking through FM help I saw this:

      Define a global field called Count Field in one of the tables in your database.

       

      Set Field [<table name>::Count Field; <table name>::Count Field + 1]

        If [<table name>::Count Field > 4]

        Save a copy as ["Backup Copy.fmp12"; copy]

        Set Field [<table name>::Count Field; 0]

        End if

       

      Backs up the DB every 5th close.

       

      I’m stuck on resolving the OnTimer continuing and how to integrate that with a Backup.

       

      I’d appreciate any guidance.

       

      Henry Barnett

        • 1. Re: OnTimer continues when layout is closed.  Adding backing up to the script.
          DavidKamar

          Have your DB do the "Install OnTimer script[]" script step without passing it any parameters when you exit.

          This stops it from running again.

          • 2. Re: OnTimer continues when layout is closed.  Adding backing up to the script.
            AitchB

            Thanks for that but how does the script know what to do (run exit script) and after how long (nn seconds)?

            • 3. Re: OnTimer continues when layout is closed.  Adding backing up to the script.
              fmpdude

              A couple of ideas I might try if FMP isn't the right backup solution or can't do what you want...

               

              1. To automate tasks like doing something like copying a file when you close an application, look at Keyboard Maestro. It's an extremely cool keyboard macro utility (about $36). You could setup a macro that when you close an application, a "copy" happens (or many other actions). KM has many triggers you can use. This tool is one that saves me lots of time every day.

               

              ----

               

              2. Look at a utility called "Hazel". Hazel is an incredibly useful utility that monitors folders and can do actions at various times. Hazel has an "Upload" action (and sync) that includes:

               

               

              Using Hazel and an ScanSnap scanner, I've been 100% paperless for 2 years! It's amazing.

               

              -----

               

              Probably the coolest utility you can get on the Mac to make things like regular "copy" commands easy is a utility called "ExpanDrive". ExpanDrive on WIndows "Maps" a drive. On the Mac it creates a volume, but it's all the same idea.

               

              Once you create a "drive" using ExpanDrive, you treat it like any other disk on your system.

               

              Here are the systems that ExpanDrive can connect to:

               

               

              My personal preference is to externalize as much functionality as possible (when it makes sense).

               

              YMMV.

               

              HOPE THIS HELPS.