|
|
|
|
TechNotes
MioScript Reference
Products
|
|
TechNote MioScript: Conditions | Language: MioScript
|
| | MioEngine evaluates conditions to determine if a code is to be interpreted.
In the following example, an alert is prompted depending on the result of the condition:
if(&firstVar = &secondVar)
alert("Variables are equals")
if.else
alert("Variables are NOT equals")
if.end
|
For more information: if, if.else, if.end
| Comparison Operators| |
= Equal
!= Not Equal
> Greater than
>= Greater than or equal
< Less than
<= Less than or equal
Below are some conditional expressions:
25 = 25 // 25 is equal to 25 (result is true)
25 != 25 // 25 is not equal to 25 (result is false)
25 < 25 // 25 is less to 25 (result is false)
25 <= 25 // 25 is less or equal to 25 (result is true)
25 > 25 // 25 is greater to 25 (result is false)
25 >= 25 // 25 is greater or equal to 25 (result is true)
|
Multi-conditional expressions| |
You can use && (and) and || (or) to create multi-conditional expressions.
In the following example, the alert is prompted if the two variables are equals and if third one is set to true.
if(&firstVar = &secondVar && &thirdVar = true)
alert("Result is true!")
if.else
alert("Result is false!")
if.end
|
Below are some multi-conditional expressions:
25 = 30 && 10 = 10 // 25 is equal to 25 AND 10 is equal to 10 (result is false)
25 = 30 || 10 = 10 // 25 is equal to 25 OR 10 is equal to 10 (result is true)
|
Functions Calls in Conditions| |
You can call functions in conditions as follow:
if(&firstVar = str.left(&secondVar, 10))
...
if.end
|
|
Single Line Conditions| |
A single line condition is a quick way to peform a comparison with the following syntax:
?(condition, result_if_true, result_if_false)
|
In the example below, the variable &result is set with Positive if the value of the variable &count is greather or egual to 0, and Negative if the value of the variable is less than 0.
&result = ?(&count < 0, "Negative", "Positive")
|
The following code is equivalent:
&result = ?(&count >= 0, "Positive", "Negative")
|
For more information: ?
|
|
|
|