Variable Arithmetic

Even though variables are represented as strings, you can perform arithmetic on them. E.g.

s = "1"
x = s + 2    // x now contains the string "3"
y = 2 * x + 5 // x now contains "11"

 

Using variables numerically is very natural and normally you don't have to even think about how they are stored. The only time you need to be careful is if a variable might contain a string that does not evaluate to a number. In that case, an error is generated. For example:

s = "hello"
    x = s + 1 // error

You can tell if a string is numeric by calling the IsNumber function.

if (IsNumber(x))
    x = x / 4   // okay to do arithmetic

Floating-point numbers are not supported.