Why do negative numbers not work?

I'm finding killer problems with negative numbers.

For example, this very simple test script:
Table: Testing
Set: FirstVar=4
Set: SecondVar=2
Set: ThirdVar=-2
FirstVar={$FirstVar}\n&
SecondVar={$SecondVar}\n&
ThirdVar={$ThirdVar}\n&
FirstVar plus SecondVar={! {$FirstVar} + {$SecondVar} }\n&
FirstVar plus ThirdVar={! {$FirstVar} + {$ThirdVar} }\n&
FirstVar times SecondVar={! {$FirstVar} * {$SecondVar} }\n&
FirstVar times ThirdVar={! {$FirstVar} * {$ThirdVar} }

Generates the following output:
FirstVar=4
SecondVar=2
ThirdVar=-2
FirstVar plus SecondVar=6
FirstVar plus ThirdVar=(Invalid expression: 4 + -2 )
FirstVar times SecondVar=8
FirstVar times ThirdVar=(Invalid expression: 4 * -2 )

Obviously, it can't deal with negative numbers. Has no one found that before? And in the mean time, how do I get around that?

Comments

  • Simple change, enclose any negative values or variables that might contain a negative number in regular brackets ()

    Table: Testing
        Set: FirstVar=4
        Set: SecondVar=2
        Set: ThirdVar=-2
        FirstVar={$FirstVar}\n&
        SecondVar={$SecondVar}\n&
        ThirdVar={$ThirdVar}\n&
        FirstVar plus SecondVar={! {$FirstVar} + {$SecondVar} }\n&
        FirstVar plus ThirdVar={! {$FirstVar} + ({$ThirdVar}) }\n&
        FirstVar times SecondVar={! {$FirstVar} * {$SecondVar} }\n&
        FirstVar times ThirdVar={! {$FirstVar} * ({$ThirdVar}) }
    

Leave a Comment