1 Reply Latest reply on Mar 3, 2010 8:46 AM by philmodjunk

    Install on Timer



      Install on Timer & Exit Application


      Good Afternoon,


      I would like to write a script to save a copy of my file, then shut down FMP every evening at 9pm or so.  (A backup program will then backup the file sometime later.)  I am hoping to use Install on Timer with the Save a Copy as and Exit Application commands to do this.  I'm new to FMP and DB's in general, and although I've searched, I can't find answers to some of my questions. 


      My system:  FMP 10, OSX 10.4, 3 users.  A Mac Mini is a server and also hosts one of the three users.  At the time the scripts would run, the two users on the network are always logged out.  Random Roxie, the user on the Mac Mini is probably not logged out, and can't be trusted to log out every day.  But I think I read somewhere that if the network users are logged out, the exit application command will close the local user and exit.  If that won't work, then I need another script to exit that user.


      First, this is what I have think might work, but I haven't gotten it to work.


      Install OnTimer Script ["Exit App 9PM; Interval 600] 


      This is the Exit App 9PM script:

      If [Get ( CurrentTime) > 9 PM and Get ( CurrentTime ) <11 PM]

         Save a Copy as [copy] (this will point to the local drive)

         Exit Application

      End If


      My basic idea is to have the script run every 10 minutes, check the system time, and if the time is between 9 pm and 11 pm, save a copy as, and them exit the application.  The program will then be restarted the next morning.  (I want to restart it daily, as when we leave FMP up and running for a while, we seem to get to get errors where records don't commit and are lost.  I thought it was operator error first, but now I think it's FMP.)


      There are several things I don't know.  For the Install OnTimer Script:

      1) I am not sure what triggers this script, or how to assign a trigger to it.  (I've written and triggered other simple scripts.)

      2) I am not sure how the script is applied to a window.  (I only use one window.)


      For the If script, I don't know the correct nomenclature, or if what I am trying will work in an If script.  I would prefer that the Save a Copy as step uses the same name every time and overwrites the previously saved file.  The backup in the cloud will keep the daily versions.  Can somebody please give me some advice?


      Thanks much for your help.  If you're in Denver, stop by for a really good cup of coffee.




        • 1. Re: Install on Timer & Exit Application

          Install OnTimer is the script trigger that will trigger the script. In your example, the Exit App 9PM script will will be run every 10 minutes (600 seconds) starting from the instant the script step Install OnTimer is performed. Every 10 minutes appears way too short an interval for this script. You might try 3600 seconds (1 hour) as an interval instead. If you only have one window, don't worry about the window references in the help file for Install OnTimer. Since you only have one window open, that's the window Install OnTimer Refers to. If you had multiple windows, you could install a different OnTimer event on each window. You aren't doing that so don't worry about it.


          You'll need to change the format of this line:

          If [Get ( CurrentTime) > 9 PM and Get ( CurrentTime ) <11 PM]

          so that filemaker correctly compares time values instead of text.


          If [ Get ( CurrentTIme ) > Time ( 21 ; 0 ; 0 ) and get ( CurrentTime ) < Time ( 23 ; 0 ; 0 ) /* times are converted to 24 hour format */]


          The big question is what happens if this script fires and someone like "Random Roxie" still has a client session open.

          If you were to simply select quite from the file menu while another user is accessing a file hosted on that computer, you get a dialog telling you that someone else is accessing the database and filemaker is waiting for them to disconnect. Exit application does the same thing so if "Random Roxie" leaves her computer up and logged into the database, your script will be left paused with no back up copy made when you come in to work the next morning.