Compare

The Compare building block compares two values A and B, using a comparison method such as “equals” or “less than or equal to”. See the Use Numbers and Variables lesson for an example of how to use the Compare block.

 Fully expanded, the Compare block shows the following properties:

Compare

The Block Header (“Compare”)

The green input connector in the header is used to trigger the block to start executing.

The green output connector in the header triggers if the comparison has a true / successful result.

The title of the block (“Compare”) can be changed by double-clicking on it and typing in a new title.

Value A

The first value to use in the comparison.

Value B

The second value to use in the comparison.

Incorrect

Triggers when the comparison results in an unsuccessful or false outcome. For instance, if Value A is 100, Value B is 200 and the comparison method is “Greater than”.

Comparison method

Select which comparison method to use (Equal, Not equal, Greater than, Greater than or equal, Less than or Less than or equal).

Comparison type

Select which data type to use for the comparison. Values are automatically converted to appropriate data types, but in certain cases it can make sense to select which type to use.

Choosing the wrong comparison type can have unforseen consequences, so choose carefully. For instance, comparing the text “200,200” with the position 200,50 results in false, but comparing position 200,200 with position 200,50 results in true.

 

Updated April 20th 2018.