What does the Set Variable "check expression" button do?

I've just added a "set variable" action to a project, and I'm trying to invert a boolean. So I typed "not %foo%" and hit the tick box, and it popped a dialog that says "Expression is Valid". Cool. Unfortunately when I run that action I get an error "'not False' is not a valid boolean value". So I'm wondering what the "expression is valid" claim actually means, and how it's supposed to be used.

I'deally I'd like to put an expression like that straight into a ProprertySet assign properties action, but that doesn't work either. The help is, as is so often the case, helpless. Apparently I can put variables in there but not expressions. Or perhaps my "valid expression" is wrong. Or something.

I've attached a screenshot that shows the joy.

The “expand expression” checkbox doesn’t do validation, it specifies whether to replace any variables in the value of the new string. So for example, your “foo” variable contains “false”.

Set variable X to “not %foo%” with “expand expression” checked: X contains “not false”

But:

Set variable X to “not %foo%” with “expand expression” unchecked: X contains “not %foo%”

Of course, when you go to display the contents of X it will probably be substitude then anyway, so the only time it matters is if the contents of “foo” changes between when you set X and when you use X.

Steve

Sorry, I was not talking about the “expand expression” checkbox, but the button-with-tick on the right hand end of the “New Value” edit box. Unfortunately the hint for that button is “New Value”.

Hi Moz,

Sorry for the confusion. As Steve pointed out, the notion of an "Expression" here is one where you expand variables into their values. The checkbox only validates whether or not the "variable" expression string is well-formed (ie all the variables exist, all the % signs are in the right place, etc.)

Unfortunately, the Set Variable action doesn't currently support any operators of any kind (ie no !, not, +, -, etc.) I've added this to the to-do list for a future release.

In the meantime, the solution is to use some script. If you add a Run Script action to your project, then click on the Script Editor tab and the OnExecute script event, you can do something like this:

VBScript:

A = not A


Alternatively:

FBVariables.A = not FBVariables.A

JavaScript:

A = !A;

Alternatively:

FBVariables.A = !FBVariables.A;


I'll update the hint on the tickbox, and see what can be done about the help topic.

Regards,

Angus

 

NB: I moved this thread from the FBServer General Discussion to FinalBuilder General Discussion.