5 Replies Latest reply on Mar 5, 2012 4:22 PM by philmodjunk

    Copying a Script using a Script

    autumnsky

      Title

      Copying a Script using a Script

      Post

      I have a database solution that is being used by multiple users on local machines. I would like to update one of the scripts in the database.

      Is it possible to copy a script from one database to another database using a script from one of the databases (actually rewrite the original script)?  I appreciate your help.  Cheers.

      I'm using FMPRo 10 Advanced

        • 1. Re: Copying a Script using a Script
          philmodjunk

          This cannot be done with a FileMaker script.

          • 2. Re: Copying a Script using a Script
            autumnsky

            Grrr, not the answer I had hoped to hear. Thanks for your time.

            • 3. Re: Copying a Script using a Script
              philmodjunk

              What problem are you trying to solve by using one script to copy and modify another? Perhaps there is an alternative approach that will work.

              • 4. Re: Copying a Script using a Script
                autumnsky

                Nice of you to ask.

                My database solution is rather complex, 12 interrelating tables with probably 50 scripts doing magic behind the scene. I have given users the ablity to execute scripts but not to modify scripts. .

                I guess what I'm looking for are simple ways to make modifications to scripts. My hope was to be able to shuttle the newly modified script from a simple database that they would download. The downloaded database would log into their database and access established admin account that could then be used to modify an existing script.

                I'm openned to any alternative approach.

                • 5. Re: Copying a Script using a Script
                  philmodjunk

                  With out more details I can't make suggestions with much confidence that what I suggest will work for you.

                  FileMaker scripts are usually very layout sensitive, even small changes to the script or the context in which it is performed and what worked before now fails.

                  I'd take a look at the following scripting methods to see where you might be able to provide much of the flexibility for which you are looking without needing to create new scripts in order to do so:

                  Set Field by Name can refer to any table occurrence and any field in your database solution as it evaluates an expression to produce the table::FieldName format used in the more commonly used set field step. (Proper layout context must be established, however.)

                  Get Field is s useful companion to set field by name as it evaluates an expression to determine the table::fieldName from which to "read" data.

                  Get (ScriptParameter) can be used to extract multiple items of data passed to the script via the "optional script parameter box" used with buttons, script triggers, Perform Script and server based script schedules.

                  Combining these concepts might produce a script fragment such as:

                  Set variable [$TargetField ; value: Getvalue ( Get ( ScriptParameter ) ; 1 ) ]
                  Set Variable[$SourceField ; value: Getvalue ( get ( ScriptParemter ) ; 2 ) ]
                  Set Field by Name [$TargetField ; GetField ( $SourceField ) ]

                  And inside the script parameter box that passes a parameter to this script, you might use an expression such as:

                  List ( GetFieldName ( TargetTable::Field ) ; GetFieldName ( Sourcetable::field )  )

                  And then there are the Let and evaluate functions to produce even more indirection.

                  One of my recent script parameters looks like this:

                  "Let ( [ $Message = " & Quote ( "Check your tag counter before printing anymore tags. It may need adjusting." ) &
                         " ; $WindowName = " & Quote ( "WARNING" ) &
                         " ; $ButtonList = " & Quote ( "OK" )  & " ] ; 1 )"

                  Inside the script, I have a step near the beginning of  it like this:

                  Set field [$Dummy ; value: Evaluate ( Get ( ScriptParameter ) ) ]

                  It assigns the number one to $Dummy. As a side effect, it creates the three variables, $Message, $WindowName and $ButtonList and assigns values to each as specified in the expression passed as text in the script parameter.