Boolean math in tinderbox


(John Lachapelle) #1

I’d like to use booleans with other variables. Assume that true = 1, and false = 0. Is this possible? I realize that I can write a test that sets ANOTHER variable to 1 or 0 using the boolean as the test, i.e. (if boolean == true, then variable = 1). But I’d have to write that test for a bunch of variables. Is it possible in tinderbox math to use the boolean directly?

Thanks for any help…

John L


(eastgate) #2

You can sometimes get away with this, but beware of unexpected string coercions. When you want “1”, you may actually get “true” and wind up with unexpected results.

I’ve found that, whenever I feel the need for something like this, a simple if() is clearer and easier.

If you really need this, send me an email explaining a bit more about the situation. We could, for example, rig up something like

  $MyBoolean.asNumber

that explicitly coerces a boolean to a numeric value.


(Mark Anderson) #3

[deleted - already answered by previous reply whilst writing mine]