2 Replies Latest reply on Oct 10, 2011 11:38 AM by Dav

    Script to Open and Close a FM data base



      Script to Open and Close a FM data base


      I have script that makes a copy of the current (modified) file using a calculated file name. I then want to open the newly saved file and close the current file. The problem: Saving a copy of the file insists on displaying a dialog window and asking for the user to supply a file name. Since I already have a pre-defined file name (by calculation) I do not want the user to input a file name in the dialog window. How do I bypass the dialog window and avoid having the user input a file name?

      I'm thinking I have a syntax problem even as I stare at the script for days wondering what could be wrong. Am looking for a better script please.

      #$filepath is set to current path

      #Value: user specified 1 of 4 seasons and year

      #Season Name and Session Year are global variables

      Set Variable [$filepath; Value:"Sr Ctr " & Members::Season Name & " " & Members::Session Year & ".fp7"]

      Save a Copy as [$filepath"; Automatically Open; copy]

      Close File [Current File]

      Do I need to use $filepath or $$filepath or what ??

      Any help would be appreciated

        • 1. Re: Script to Open and Close a FM data base

          You may have a couple of problems;

          - If you manually specify a file name in the 'Specify Output..' box of 'Save a Copy' you'll see that it is prefixed with a 'file:..' syntax.  I think I would repeat that.
          - When you set that saved file to open, and then the next script step is 'Close Current File', does it not close the file it has just opened?  Do you not have to take the focus back?  (Can't remember, hence my question.)
          - You have specified the variable as $Variable, so that's the one to use.  I don't see any need to specifiy it as a $$Variable.  I expect it's a typo, but you have a quotation mark after the Save a Copy as [$filepath"...

          But I am ever surprised at the number of people who post that they have problems taking repeated copies of files, saving in the correct location,  renaming them with dates, years, players' names, etc.  In 20 years I have only ever (I think) saved regular copies as backups.  If you are trying to catagorise sets of records by season year and session, why not log that in the record and keep them all in the same file?  If people are sending you files, why not import the records?  If you want to exclude viewers from certain records why not set that in the privileges?  I'm starting to feel that some bit feature - or exposure - of FM has passed me by.  If you want it as a form of regular backup Phil has posted a 'Developer's Friend' back up script that would work well here - just change the trigger from being time-based.

          • 2. Re: Script to Open and Close a FM data base

            Sorbsbuster... Thank you for your timely reply. Oops! The extra quote mark of Save a Copy as [$filepath is my mistake - it's not in my actual script. I'll try repeating the 'file' prefix - that's a good suggestion. Also I could put ALL records in the same file separated by each season of the year and have the user log into a specific season... an excellent idea! 

            Yes, the original (modified) file stays in focus even after the newly named file is automatically opened. So, in my case, Close File does close the original (modified) file, giving the newly named file the focus as expected. If the focus were the other way around I would think my next script step to Open (the New) File would never get  executed.

            To clarify my purpose in all this file opening and closing... The complete script saves a copy of the current (unmodified) file

            • then Finds and deletes all records that are out of date

            • then saves the modified file using a new pre-defined file name

            • then opens the newly defined file (not on focus)

            • then closes the current (modified) file under the original file name

            • leaving the new modified file (with the new name) on focus.

            This gives me a copy of the original file (unmodified), a modified file under the original file name (discarded manually), and finally a modified file under the new file name.


            I'll attempt to employ your suggestions and see if that works. We are all senior citizens so having them choose the correct season can be iffy at times! Tongue out Thanks a bunch.