In AskiaScript, a boolean variable contains a boolean value (true or false).
The boolean value is internally stored as a number where zero means false and all other values are interpreted as true. It is therefore possible to use all properties, methods and operators available for numbers with boolean variables.
In this topic:
To create a boolean type variable, simply assign a boolean value to a variable.
Dim valueB As Boolean = 1
Dim valueC As Boolean = False
Dim valueD As Boolean = 0
Dim valueE As Boolean = 126 ' => valueE = True
valueE.ToInt() ' => 1
Converts a boolean value to a number:
Returns a Number.
dim ok As Boolean = true ok.ToNumber() ' => 1
dim ok As Boolean = 12456 ok.ToNumber() ' => 1
dim not_ok As Boolean = false not_ok.ToNumber() ' => 0
Converts a boolean to string.
Returns a String.
dim ok As Boolean = true ok.ToString() ' => "true"
dim not_ok As Boolean = false not_ok.ToString() ' => "false"
Always returns "boolean".
Returns a String.
dim my_boolean As Boolean = true my_boolean.TypeOf() ' => "boolean"
' Without the AS Boolean, the type of the variable is a number dim my_variable = true my_variable.TypeOf() ' => "number"
Number
|
Name |
Symbol / Expression | Description | Example |
|---|---|---|---|
| Equal | = | Test the equality Returns a number To use it for comparison, the condition should be between brackets else it will be consider as an assignment operator |
dim i As Boolean = false (i = true) ' => False (i = false) ' => True |
| Different | <> | Test the inequality Returns a number |
dim i As Boolean = false i <> true ' => True i <> false ' => False |
| Negate | Not() | Negate a statement Returns a number or boolean |
dim i As Boolean = true dim j As Boolean = false Not(i) ' => False ' => Boolean Not(j) ' => True ' => Boolean Not((i = j)) ' => True ' => Number Not((i <> j)) ' => False ' => Number |
| And | And | Use this operator to define statements which are based on a specific combination of two or more variables Returns a boolean |
dim i As Boolean = true dim j As Boolean = false dim c As Boolean = true dim d As Boolean = false i And j ' => False j And d ' => False i And c ' => True |
| Or | Or | Use this operator to define statements which are based on a two or more interchangeable/equivalent statements Returns a boolean |
dim i As Boolean = true dim j As Boolean = false dim c As Boolean = true dim d As Boolean = false i Or j ' => True j Or d ' => False i Or c ' => True |