5 Replies Latest reply on Oct 27, 2008 5:15 AM by Nat

    Scripts

    Nat

      Title

      Scripts

      Post

       

        • 1. Re: Scripts
          davidhead
            

          Hi Nat

          The first thing I need to say is that your use of a global field here has some limitations in a multi-use scenario. I would assume that you are using this in a scenario where you are the only user and the host. In that case, any change you make to the value of the global field will 'stick' when you close and re-open the file. That would not be so for a multi-user solution. I would advise looking at this from a more robust point of view for the sake of your current solution and where it may go in future.

           

          I suppose that another point is that the Save a Copy As script step (and the menu item) is not available for guests of a solution. So you are probably using this as a single user.

           

          Another point is that your script will necessarily overwrite the previous backup so you must have something in place to make it a real backup (to other media and offsite?). 

           

          When does the Count Field get incremented? Is that part of an opening script? 

           

          Does the daily backup script you have shown get run each time the database is closed?

           

          Anyway, back to your question. What is actually going wrong for you? Does the saved copy happen? Does the Set Field happen?

           

          If you are interested in a better way of doing this, perhaps you can outline the process that you want to happen each day. Then I can turn that into a solid scripted process for you. 

          • 2. Re: Scripts
            davidhead
              

            Nat wrote:

            The script saves a copy of the database on the fifth close and every fifth close thereafter. The script saves a copy, only now nothing is happening.

            I can't enter the last script step because when the dialog box pops up to enter the  0 at the end, it's asking for an operator.


            OK I have had a look at the help page you are referring to. In essence the script will work but not in a multi-user solution. There should be some sort of caveats mentioned there.
            Your problem is that you cannot set the value for the second Set Field step? When you add the step to the script and then select it, there are two options at the lower right of the dialog - Specify target field and Calculated result. Click the first Specify... button to open the dialog to select the global field. Click OK to that, then click the Specify... button for the Calculated result. In the resulting Specify Calculation dialog, enter 0. Just 0, no quotes, nothing else. Click the OK button to close the dialog and that should be it.
            See if that works. 

             


            • 3. Re: Scripts
              Nat
                

              The script is now

              If [Product Catalog::gfile > 4]

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

              Set Field [Product Catalog::gFile; Product Catalog::gFile + 1]

              Set Field [Product Catalog::gFile; 0]

              End If

               

              The output file list is specified for Backup Copy and when I open Backup Copy after running the script, the changes made in Product Catalog are not in Backup Copy. In the example script there are<> around the table name but not in the script I ran. When I enter the <>around Product Catalog a message pops up that says an operator is expected here.

              • 4. Re: Scripts
                davidhead
                  

                Nat wrote:

                The script is now

                If [Product Catalog::gfile > 4]

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

                Set Field [Product Catalog::gFile; Product Catalog::gFile + 1]

                Set Field [Product Catalog::gFile; 0]

                End If

                 

                The output file list is specified for Backup Copy and when I open Backup Copy after running the script, the changes made in Product Catalog are not in Backup Copy. In the example script there are<> around the table name but not in the script I ran. When I enter the <>around Product Catalog a message pops up that says an operator is expected here.


                Hi Nat
                You have the incrementing script step inside the If/EndIf instead of at the start.  That means it will only increment if gfile > 4 and then will reset gfile to zero. Move the third step to the start:

                Set Field [Product Catalog::gFile; Product Catalog::gFile + 1]

                If [Product Catalog::gfile > 4]

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

                  Set Field [Product Catalog::gFile; 0]

                End If

                What the script now does is to increment the gfile field each time the database closes. If, after an increment, gfile > 4, then it will back up the file and then reset gfile to zero.
                Just to make sure it is working, you could put a custom dialog step in after the Save a Copy step that tells the user that a backup has been made (and reminds you to copy it to external media).
                The other difference in file name you noted between your script and the one in the help file are OK - your script looks fine. 

                 


                • 5. Re: Scripts
                  Nat
                    

                  David:

                  Ultimately I'd like to create a script for multi-users for a backup each time the database is opened. I am open to ideas in terms of a script to remove toolbars as well.

                   

                  Thank you,

                  Nat