Code: Select all
vTest := "1,000"
vTestOut := "26"
MsgBox, 64, Difference, % vTest := subtractStrings(vTest, vTestOut)
subtractStrings(str1, str2) {
Return StrReplace(str1, ",") - StrReplace(str2, ",")
}
A demonstration:
Code: Select all
vTest1 := 1,000
vTest2 := 3,4,5,6,7,8,9
MsgBox, %vTest1%
MsgBox, %vTest2%
Explained:
https://www.autohotkey.com/docs/commands/SetExpression.htm
A string with commas is not interpreted as a number.
An expression with commas is interpreted as multiple expressions (I believe).
My best explanation of this is that the value of an expression containing commas is equal to the value of the first expression in the list. Others may have a more technically accurate description.
Code: Select all
vTest2 := (3,4,5,6,7,8,9)
MsgBox, %vTest2%
Another demonstration of expressions:
Code: Select all
Send % (3, c := 5, a := "9")
MsgBox, %c%
MsgBox, %a%
The answer to your question is straightforward and is the same answer previously provided in this thread: you remove the commas before you introduce the mathematics.
And now for the final exam, to see whether you learned something.