IsDigit is more sensitive to what the contents of the variable are
Code: Select all
#Requires AutoHotkey v2.0
#SingleInstance Force
; x := '123' ; Correct
; x := 'A12' ; Wrong info
; x := '12&' ; Wrong info
; x := '1,2' ; Wrong info
; x := '' ; Wrong info
x := 0 ; Correct
; x := "0" ; Correct
if !isInteger(x)
{ MsgBox x "`t (is NOT an Integer)"
}
if !isDigit(x)
{ MsgBox x "`t (is NOT a Digit)"
}
If !RegExMatch( x, '^\d+$' )
{ MsgBox x "`t (Not an Number)"
}
In the example above, the following error is generated
"IsDigit requires a String, but received an Integer."
A user rarely sees a difference on
var := 10 or
var := "10"