You can distinguish between expressions ( := ) and "normal" values ( = ). Your goal can be satisfied with several approaches, as shown in the following examples:
a := 5 b := 7 x := 6789 ; String concatenation str1 = %a%%b% ; or as an expression str2 := ab ; or with explicit concatenation operators str3 := a . b ; Mathematical "concatenation" ; if b has exactly one digit val1 := a*10 + b ; for any integer val2 := a * (10**StrLen(x)) + x ; ** is the "power" operator msgbox, str1 = %str1%`nstr2 = %str2%`nstr3 = %str3%`nval1 = %val1%`nval2 = %val2%
This code will print:
str1 = 57 str2 = 57 str3 = 57 val1 = 57 val2 = 56789
In AHK, all of these methods must be quasi-equivalent: they produce the same output. The mathematical approach marks variables as numbers, leading to possible trailing zeros that you might want Round() before displaying. The result of our string concatenation can also be used as a number, since AHK automatically blocks them if necessary. For example, you can calculate z := str1 - 1
and he will rate to 56 .
I personally prefer the mathematical approach, as this will result in the actual number rather than the string, which seems logical.
Mcl
source share