Block Group: | Logic |
Icon: |
The If block returns one value if a condition that you specify evaluates to TRUE and another value if the condition evaluates to FALSE.
For information on using dataflow blocks, see Dataflow.
The following properties of the If block can take input and give output.
op specifies the arithmetic, comparison, or text operator to apply to the input values. It is used in conjunction with input n to form an expression that can be evaluated to TRUE or FALSE. The value of the op property can be one of the following:
input n specifies two or more values to be evaluated using the operator specified.
then specifies the value to return if the expression evaluates to TRUE.
else specifies the value to return if the expression evaluates to FALSE.
The following property of the If block can give output but cannot take input.
output returns either the then value or the else value. The then value is returned if the expression evaluates to TRUE, and the else value is returned otherwise.
The following image demonstrates two examples of the If block. In this image, the leftmost If block returns “Within Budget” if the bound value is less than 100 and returns “Over Budget” otherwise. The rightmost If block returns twice the value of input 0 if input 0 is less than 100 and returns 100 otherwise.