6 Replies Latest reply on Jul 11, 2011 11:20 AM by BradenDouglass

    Multiple File Variable Passing

    BradenDouglass

      Title

      Multiple File Variable Passing

      Post

      I know how to get scripts in one file to fire in a sepearate file however, I was wondering if there was anyway to pass variables from file to file? Perhaps I had a value that I wanted to transfer during the script in order for it to finish. Thanks for the help.

        • 1. Re: Multiple File Variable Passing
          philmodjunk

          You can pass your values as a script parameter.

          List (value1 ; value2 ; value3)

          is one way to send multiple values to the script as long as value1 and value2 are never empty.

          GetValue ( Get ( ScriptParameter ) ; 1 )

          Would then retrieve value 1.

          It's also possible to pass text that looks like this as your script parameter:

          "Let ( $variable1 = " & value1 & "$variable2 = " & value2 & "$Variable3 = " & Value3 & " ; 1 ) " )

          Then this step at the start of the script can set all three variables with their values:

          Set Variable [$Dummy ; Evaluate ( Get ( ScriptParamter ) ) ]

          This second option works correctly even if value 1 and value 2 are empty, but it's a good idea to add an extra comment or three at the top of your script documenting what you've set up if you use it so you can more easily figure out how it works when you look at it in the future.

          • 2. Re: Multiple File Variable Passing
            BradenDouglass

            Hmm Phil, thank you for this. One question, when you pass the values into the list are those values variables? Or should they be values from the current table? Or should you establish a variable with the List (value1 ;) function? I have built something spartan to test it all but I can't get the values to pass along. I am establishing a variable, naming it, and in the second field (value field) establishing the List calc with List(nameofLayout::NameofField). Any idea where I am going wrong? Thank you.

            • 3. Re: Multiple File Variable Passing
              philmodjunk

              If you want the values as variables in the script where they are passed when you send a list of values, use a series of set variable steps at the start of your script to extract the individual values from the parameter list and place them in variables.

              If you paramater list has three values, here's one way to set it up:

              Set Variable [$Variable1 ; value: GetValue ( Get ( Scriptparameter ) ; 1 ) ]
              Set Variable [$Variable2 ; value: GetValue ( Get ( Scriptparameter ) ; 2 ) ]
              Set Variable [$Variable2 ; value: GetValue ( Get ( Scriptparameter ) ; 3 ) ]

              Now you've converted your parameter list into individual variables. This, when placed at the top of your script also help document the structure of your parameter list--which can make understanding your script easier when you work with it at a later date.

              • 4. Re: Multiple File Variable Passing
                BradenDouglass

                Gotya,  Now to set the orgiin script parameter (in the first file) do you recommend using generic if/else statements to set them up? Or is there another way to build the list of Get(ScriptParameter) values?

                • 5. Re: Multiple File Variable Passing
                  philmodjunk

                  Usually, you can just use: list ( value1; value2; value3)

                  Just add Perform Script to your script. Select the script in the other file and enter the list function in the "optional script parameter" box.

                  Any number of different expressions can be put in place of value1; value2; value3 depending on the needs of your scripts. Not sure where you would use "generic if/else statements" in this.

                  • 6. Re: Multiple File Variable Passing
                    BradenDouglass

                    Thank you, works insanely perfect. I guess I am going to need to brush up on the Get and Script Parameter information. I only sudo understand what is going on under the hood in this script.