Page 1 of 1

Confusion with number strings

Posted: 22 Jul 2017, 16:27
by slimpickens
Why is this blank, I thought ahk treated number strings as numbers in this case?

Code: Select all

[code]
oldCount = 1,234,000 
newCount = 1234500
change := newCount - oldCount ; empty

Re: Confusion with number strings

Posted: 22 Jul 2017, 16:42
by kon
Hey, try this:

Code: Select all

var := "1,234,000"  ; Note the non-digit characters (',')
MsgBox % var + 0

var := "1234000"
MsgBox % var + 0
HTH :)

Re: Confusion with number strings  Topic is solved

Posted: 22 Jul 2017, 17:05
by jeeswg
Could be good:

Code: Select all

q::
oldCount = 1,234,000
newCount = 1234500
oldCount := StrReplace(oldCount, ",")
MsgBox, % change := newCount - oldCount
return

w::
oldCount = 1,234,000
newCount = 1234500
MsgBox, % change := newCount - StrReplace(oldCount, ",")
return

Re: Confusion with number strings

Posted: 23 Jul 2017, 08:16
by slimpickens
jeeswg wrote:Could be good:
Nice one, this made me realise that the google sheets api I used defaults to formatted values, I changed it to unformatted and I don't need to convert it in ahk anymore.