3 Replies Latest reply on Apr 26, 2009 9:54 PM by obeechi

    variable script name

    bchi09

      Title

      variable script name

      Post

      Question:

      I am not sure how to perform a script based on a variable name?

       

      1 if a active field contain ="M"

      2 then get the field name

      3 find the script name that matches the field name

      4 then perform the matching script 

       

      step 1 & 2 I have no problem but 3 & 4 I am lost. 

        • 1. Re: variable script name
          FentonJones
            

          There is no: Perform Script [ by name ] ability, as yet anyway. About the best you can do is to create a series of

          If [ something = "something" ]

          Perform Script [ "Something" ] 

          Else If [ something = "something else"

          Perform Script [ "Something Else" ] 

          etc.

          End If

           

          Or, if there are only minor variations in the different scripts, you can use a Script Parameter, and do the If's based on that, using Get (  ScriptParameter ) to get it.

           

          It is a little odd, because AppleScript can run a FileMaker by name (in fact it has to). So if you're only on Mac, that's an option; you can run it in FileMaker with the Perform AppleScript step.* But FileMaker internally cannot; hence the "yet", as it seems likely that some day it will be able to.

           

          *Do not however expect this to still work if you change the script names; that is the tradeoff. 

          • 2. Re: variable script name
            bchi09
               Thank you, I will have to just do it the old fashion way.
            • 3. Re: variable script name
              obeechi
                

              Let the active field you refer to be a button. Let the button have one script: Perform Script (ideally buttons would only have Perform Script attached, and no other script step ever). In Perform Script's parameter box just type in the name of your field. The script that Perform Script calls will then have a Set Variable script step within it with Get(ScriptParameter) as the value (you will find your Getters under Get, more so than All-Functions-by-Name -- this is in your calculation area, aka "Specify Calculation", called up within ScriptMaker when you're setting (specifying) the Value in the Set Variable script step). Then have a section in your script (the first one called, by the button) where the first line is IF [yourVar = "script1"] and the next line is Perform Script ["script1"] and the next, or last, line is EndIF

               

               Post your script online for us when you're done, or hit a wall.