Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Panel
panelIconIdatlassian-info
panelIcon:info:
bgColor#E3FCEF

Please read the Terms of Use for Materials on ZennoLab

Table of contents

Expand
titleClick here to expand the table of contents
Table of Contents
minLevel1
maxLevel7
exclude^Оглавление$

...

Let's look at a simple example to understand this operator.

...

  1. Create a variable value1 and assign the value 1 to it .

  2. Add an IF cube using the actions " Logic " → " If "

  3. In the cube properties field, insert the operand {-Variable.value1-}

  4. Add the operator “ equals ” - ==

  5. Let's insert the second value to compare - constant 1 .

  6. Now if you run the cube (select it and press the "Next" button in ProjectMaker), then the cube will end along the green line (a green check mark will appear). This tells us that the value is correct (True), since indeed the variable value1 is 1 .

  7. Change value1 to 2 in the “Variables” window and repeat step 6. The cube will end along the red line (a red cross will appear). This tells us that the value is not correct (False), since the variable value1 is not equal to 1 .

In the example above, we used numeric data and the equals ( == ) comparison operator. In the next example, we will compare text data and for this we will use the not equal operator ( ! = ).

Warning

Important! When comparing text values, data and variables must be enclosed in quotation marks: single or double. Conversely, for numbers, quotes are not needed . Otherwise, the comparison will be incorrect. This is the mistake many newbies make.

...

  1. Create a variable value1 and assign it the value “Hello World“ .

  2. Add an IF cube using the actions " Logic " → " If "

  3. In the cube properties field, insert the operand {-Variable.value1-}

  4. Add the “ not equal ” operator - ! =

  5. Let's insert the second value to compare - the constant “Hello World“ .

  6. Now if you run the cube (select it and press the "Next" button in ProjectMaker), the cube will end with a red line (a red cross appears). And this is logical. The value in the variable is equal to the value of the second line and therefore the operator “ not equal to! = Is false and, accordingly, the die returns False .

  7. Let's change the value1 to Goodbuy World in the Variables window and repeat step 6. The cube will end along the green line and this is absolutely true, because the string in the variable differs from the value on the right side of the expression and, accordingly, the operator “ not equal! = Is true and the cube is returned by True .

In addition to the above operators, which are used to compare both numbers and strings, other operators are used to compare numbers:
< Less

...

The OR operator looks like a double vertical slash. This operator allows you to compare several conditions in a chain at once. Moreover, they are calculated from left to right. The cube will return True if any expression is true, and False if all expressions are false.

...

  1. Let's set the two variables {-Variable.value1-} and {-Variable.value2-} to 1 and 12, respectively.

  2. Add the line {-Variable.value1-}> 0 || {-Variable.value2-} <10

  3. Despite the fact that the second equality is not correct, the cube will end on the green line, because the OR operator will return True if at least one of the comparisons is correct.

  4. Correct the value of the variable {-Variable.value1-} also to false (for example, assign the number 0) and then the cube will return False (the red branch will work).

...

AND operator (&&)

The AND operator is written as two ampersands && and returns True if all its arguments are true, otherwise - False .

...

Table of all available operators

Оператор

Описание

Пример использования

<

Less

1<2

>

More

5>3

<=

Less or equal

7 <= 10

>=

More or equal

8 >= 8

==

Equally

"Hello" == "Hello"

!=

Not equal

“Hello”! = “Bye”

&&

Logical "AND"

“Hello”! = “Bye” && 5>3

||

Logical "OR"

"Day" == "Night"|| 2 > 1

...

Usage example

In practice, comparison is used very widely. For example, we need to check whether at least some text has loaded on the page or not.

...

Also, a frequent use of the “ IF ” cube is in cycles with a counter when a constant comparison of the counter with some maximum value is required - Cycles (loops).

...