2 Replies Latest reply on Feb 14, 2011 9:29 AM by philmodjunk

    Update a global variable value when global variable is value of parameter.

    unieater

      Title

      Update a global variable value when global variable is value of parameter.

      Post

      Using FMPro11 Advanced. This might be a bit over my own head, but I'm trying to update a global value.

      I'll make is simple.  $$gv1 = "N" and I want to change it to "Y".

      However, I have a number of these variables that I want to manage, so I don't want to write it over and over again, I just want call a script or custom function, and pass a parameter to update it.

      Here's where the complexity comes in (or my ineptitude).  I want to have the parameter that is passed be generic as well.  Such that the value of the generic passed item is the global value name "$$gv1", so I can turn global variables on and off with only one script of function

      To summarize a different way, the local variable value is the name of the global variable, and I want to change the value of the global variable.

      Thanks in advance all.

        • 1. Re: Update a global variable value when global variable is value of parameter.
          unieater

          Did some research most of today to find out that this is also called pass parameter as reference.  From what I can tell, this is impossible in Filemaker.

          If there is any other than IMPOSSIBLE, let me know.  For those of you following along, I've learned that Global Fields are the way to go in Filemaker.

          • 2. Re: Update a global variable value when global variable is value of parameter.
            philmodjunk

            I think you want to pass the Global Variable's name and it's value as parameters:

            Make this the expression you pass as a parameter: List ( "$$GlobalVariableName" ; Value )

            Your script can work like this:

            Set Variable [$Dummy ; value: Evaluate ( "Let (" & GetValue ( Get ( ScriptParameter ) ; 1 ) & " = " & GetValue ( Get ( ScriptParameter ) ; 2 ) & " ; 1 )") ]

            $Dummy receives the value 1, everytime, but the indirectly referenced global variable is assigned a value passed as a parameter as a side effect of this expression using Let to assign a value to the global variable named as the first parameter.