|
ANY-maze Help > The ANY-maze reference > The Protocol page > The elements of a protocol > Testing > Procedures > Elements of a procedure > Comparison operators Comparison operators
IntroductionComparison operators allow a procedure to compare two different values. The two values of the operator are the 'parameters' to the operator. Comparison operators can be one of the following:
ExampleThe following example compares the value of a variable to 1. If the variable's value is greater than or equal to 1, the procedure will perform an action.
Figure 1. In this example, the value of the 'Lever press count' variable is compared to 1; if greater than or equal to 1 (i.e. if the lever has ever been pressed) then the procedure will activate the 'pellet dispenser' switch.
More informationThese operators can accept any expression (including those that are made up of other expressions themselves). When both parameters of a mathematical operator are numeric, the result of these operations should be obvious. In fact most of these operators (>, >=, <, <=) can only be used with numerical expressions. However, an expression in a procedure can be either numeric, True/False, or a text value. If the expression contains a user-defined variable, then it's possible that the resulting type of the expression is not known until the procedure actually runs. In this case, ANY-maze will try to evaluate the expression as a number when it encounters it in the procedure. In order to do this, it will use 1 and 0 for True and False, and will attempt to convert any text expressions to a number (this is unlikely to succeed, unless the text expression obviously represents a numeric value, for example '25' or '3.14159265'). The 'equals' (=) and 'not equals' (not =) operators can be used with any type of expression. To be equal, the expressions must both be of the same type (i.e. both numeric, both True/False, or both text) as well as evaluate to the same value. In this way, the 'equals' (=) and 'not equals' (not =) operators can be used to compare built-in variables, constants, user-defined variables, and the ANY-maze protocol items found at the bottom of the Variables tab.
The following example shows the 'equals' comparison operator being used to determine the current position of a 'known' arm in a Y-maze.
Figure 2. Using the 'equals' comparison operator to determine the current location of a movable zone.
If you change your mind about which operator you're using (for example, you want to change 'greater' (>) to a 'greater than or equals' (>=), just right-click on the operator in the procedure editor. You'll get a drop-down menu which includes the Change operator option; selecting the new operator will change the operator while leaving both of its parameters intact.
© Copyright 2003-2026 Stoelting Co. All rights reserved ANY-maze help topic T0495 |