Code: Select all
a:=""
b:=0
c:=0
b:=b+a
c+=a
MsgBox % b ; b=""
MsgBox % c ; c=0
Code: Select all
a:=""
b:=0
c:=0
b:=b+a
c+=a
MsgBox % b ; b=""
MsgBox % c ; c=0
As opposed to the + operator which documents:If either Var or Value is blank or does not start with a number, it is considered to be 0 for the purpose of the calculation (except when used internally in an expression and except when using the TimeUnits parameter).
Granted, the documentation for + does also say "For example, Var+=2 produces the same result as Var:=Var+2 (though the former performs better)", which as you've seen is only true when working with numbers not empty strings. Maybe we could adjust the documentation to say "(though the former performs better, and results differ when working with empty strings)"Except where noted below, any blank value (empty string) or non-numeric value involved in a math operation is not assumed to be zero. Instead, it is treated as an error, which causes that part of the expression to evaluate to an empty string. For example, if the variable X is blank, the expression X+1 yields a blank value rather than 1.