Within an expression, checks whether a value is of a given type or is numeric, uppercase, etc.
if Value is Type if !(Value is Type)
An expression which produces the value to check.
An expression which produces a type string or object, as described below.
Type strings are case-insensitive.
integer | True if Value is an integer or 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 and must not be empty. |
float | True if Value is a floating point number or 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 and must not be empty. |
number | True if Value is "integer" or Value is "float" is true. |
object | True if Value is an object. |
byref | True if Value is a reference to a ByRef parameter and the function's caller passed a variable reference. |
Strings | |
digit | True if Value is an integer, an empty string, or a string which contains only 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. A prefix of 0x is tolerated if present. |
alpha | True if Value is a string and 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 Value contains a space followed by a letter, it is not considered to be alpha. |
upper | True if Value is a string and 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 Value is a string and 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 integers and characters 0 through 9 are also allowed. |
space | True if Value is a string and is empty or contains only whitespace consisting of the following characters: space (A_Space or `s), tab (A_Tab or `t), linefeed (`n), return (`r), vertical tab (`v), and formfeed (`f). |
time | True if Value is 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 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. |
If Type is an object, the result is true if Value is an object derived from Type, directly or indirectly. For example:
x := {} y := new x ; Equivalent to y := {base: x} z := new y MsgBox(x is x) ; False MsgBox(y is x) ; True MsgBox(z is x) ; True
is
can be used anywhere an expression is expected. Precedence rules apply, so for instance, x or y is z
is the same as x or (y is z)
.
To check for multiple types, use is
multiple times. For example, x is "integer" or x is "space"
.
Since literal numbers such as 128
, 0x7F
and 1.0
are converted to pure numbers before the script begins executing, the format of the literal number is lost. Consequently, type checks act on the decimal form of the number. For example, 0x7F is "digit"
is equivalent to "128" is "digit"
.
The system locale is ignored unless StringCaseSense Locale has been used.
A_YYYY, FileGetTime, if (expression), StrLen, InStr, StrUpper, DateAdd
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."