3 Replies Latest reply on Dec 31, 2012 9:42 AM by wimdecorte

    Global Variable for Interface Preferences


      I'm trying to use a single checkbox to turn an interface preference on and off. The way I'm doing it is by using a global field, which I set to the default value when I enter the layout, and then I toggle it between empty and 1 using the checkbox. This evaluates to False and True in boolean logic, so it works quite well. The value list that I'm using contains only "1".


      However, this functionality shouldn't, to my mind, require a global field, but instead should just need a global variable. The scope of a global variable is closer to this functionality, and it just seems neater to do it that way, so I'm trying that, but I'm running into a weird problem.


      I use a calculation field with a very simple calculation:




      And I turn the checkbox into a button, so it will report the value of $$globalVariable, and when clicked it runs this script:


      Set Variable [ $$globalVariable ; Value: not $$globalVariable ]


      In the data viewer, I can see the value of $$globalVariable toggling between 0 and 1, but it never affects the value of the calculation field. In fact, what's weirder, if the calculation field is set to return a number, it always returns 1, but if it's set to return text, it always returns 0. Setting the field to global or not, and setting "Do not evaluate if all referenced fields are empty" appear to have no effect.


      I'm quite happy to use my global field solution, because even though the global field is not the "neatest" choice, I can also see that it's actually simpler to do it that way. However, I would like to understand just what's going on with this global variable -> calculation thing. Why doesn't it work? And why does its value change when it's returning text compared to when it's returning a number?