Logic
Boolean logic is a simple mathematical system with two values:
- true
- incorrect
Logic blocks in ROBO Pro Coding are generally there to control conditions and loops.
Here is an example:
If the value of x is not greater than 100, then the condition is false, and “It’s not very big.” is output. If the value of x is not greater than 100, then the condition is false and “It’s not very big.” is output. Boolean values can also be saved in variables and transmitted to functions, just like numbers, texts, and list values.
Blocks
If a block expects a Boolean value as an input, then no input will be interpreted as false. Non-Boolean values cannot be inserted directly where Boolean values are expected, although it is possible (but not advisable) to save a non-Boolean value in a variable and then insert this into the condition input. This method is not recommended, and its behavior can change in future versions of ROBO Pro Coding.
Values
An individual block with a drop down list that either indicates true or false can be used to access a Boolean value:
Comparative operators
There are six comparative operators. Two inputs are entered into each (normally two numbers), and the comparative operator returns true or false, depending on how the inputs are compared to one another.
The six operators are: equal, not equal, less than, greater than, less than or equal, greater than or equal.
Logical operators
The and block returns true if and only if its two input values are true.
The or block returns true if at least one of its two input values is true.
do
The not block converts a Boolean input into its opposite. For example, the result of:
is false.
If there is no input, then the value true is assumed, so that the following block will generate the value false:
However, leaving an input empty is not recommended.
Three-part operator
The three-part operator acts like a miniature if do block. It uses three input values The first Boolean condition to be tested is the first input value, the second input value is the value returned if the test is true, and the third input value is the value returned if the test is false. In the following example, the variable coloris set to red if the variable x is less than 10, otherwise the variable coloris set to green.
A three-part block can always be replaced by an if do block. The following two examples are just the same.