If var is [not] type

Checks whether a variable's contents are numeric, uppercase, etc.

if Var is Type
if Var is not Type

Parameters

Var

The variable name.

Type

Specify one of the following types:

Type Description
integer True if Var is non-empty and contains a purely numeric string (decimal or hexadecimal) without a decimal point. Leading and trailing spaces and tabs are allowed. The string may start with a plus or minus sign.
float True if Var is non-empty and contains a floating point number; that is, a purely numeric string containing a decimal point. Leading and trailing spaces and tabs are allowed. The string may start with a plus sign, minus sign, or decimal point.
number True if Var contains an integer or floating point number (each of which is described above).
digit True if Var is empty or contains only digits, which consist of the characters 0 through 9. Other characters such as the following are not allowed: spaces, tabs, plus signs, minus signs, decimal points, hexadecimal digits, and the 0x prefix.
xdigit Hexadecimal digit: Same as digit except the characters A through F (uppercase or lowercase) are also allowed. [v1.0.44.09+]: A prefix of 0x is tolerated if present.
alpha True if Var is empty or contains only alphabetic characters. False if there are any digits, spaces, tabs, punctuation, or other non-alphabetic characters anywhere in the string. For example, if Var contains a space followed by a letter, it is not considered to be alpha.
upper True if Var is empty or contains only uppercase characters. False if there are any digits, spaces, tabs, punctuation, or other non-uppercase characters anywhere in the string.
lower True if Var is empty or contains only lowercase characters. False if there are any digits, spaces, tabs, punctuation, or other non-lowercase characters anywhere in the string.
alnum Same as alpha except that characters 0 through 9 are also allowed.
space True if Var is empty or contains only whitespace, which consists of the following characters: space (%A_Space%), tab (%A_Tab% or `t), linefeed (`n), return (`r), vertical tab (`v), and formfeed (`f).
time

True if Var contains a valid date-time stamp, which can be all or just the leading part of the YYYYMMDDHH24MISS format. For example, a 4-digit string such as 2004 is considered valid. Use StrLen() or StringLen to determine whether additional time components are present.

Years less than 1601 are not considered valid because the operating system generally does not support them. The maximum year considered valid is 9999.

The word DATE may be used as a substitute for the word TIME, with the same result.

Remarks

The "is" operator is not supported in expressions.

[AHK_L 42+]: The system locale is ignored unless StringCaseSense Locale has been used.

%A_YYYY%, Format(), SetFormat, FileGetTime, IfEqual, if var in/contains MatchList, if var between, StrLen(), IfInString, StringUpper, Blocks, Else, StringLen

Examples

Checks whether var is a floating point number or an integer and checks whether it is a valid timestamp.

if var is float
    MsgBox, %var% is a floating point number.
else if var is integer
    MsgBox, %var% is an integer.
if var is time
    MsgBox, %var% is also a valid date-time.