Math & Text
isInteger
$isInteger
Checks if a value is an integer (positive, negative or zero).
Syntax
$isInteger[value]
$isInteger
The function $isInteger[value] checks if a value is an integer (without decimals). It accepts positive integers, negative integers and zero.
Syntax
$isInteger[value]
Parameters
| Parameter | Description |
|---|---|
value |
The value to test. |
Return Value
- Type: Boolean
trueifvalueis an integer (e.g.42,-7,0)falseifvalueis a decimal, text, or empty.
Behavior
- Decimal numbers (
3.14,2.0) returnfalse. - Integers in scientific notation are not recognized.
0is a valid integer.- Spaces around the number can invalidate the test.
Examples
Parameter Validation
$if[$isInteger[$message[1]]==true]
$sendMessage[✅ $message[1] is a valid integer.]
$else
$sendMessage[❌ Please provide an integer.]
$endif
Pagination (Validation)
$var[page;$message[1]]
$if[$isInteger[$var[page]]==true]
$if[$var[page]>=1]
$sendMessage[📄 Displaying page $var[page]...]
$else
$sendMessage[❌ Page must be >= 1.]
$endif
$else
$sendMessage[❌ Invalid parameter. Usage: !page <number>]
$endif
Custom Counter
$var[number;$message[1]]
$if[$isInteger[$var[number]]==true]
$for[i;1;$var[number];1]
Counter: $for[i]
$endfor
$else
$sendMessage[Please enter an integer.]
$endif
Notes
$isInteger[42]returnstrue.$isInteger[-10]returnstrue.$isInteger[3.14]returnsfalse.$isInteger[abc]returnsfalse.- To also accept decimals, use
$isNumber[].