UDM - if Statement - Comparison Operations

UDM - if Statement - Comparison Operations

In an if statement, a comparison consists of three parts:

  • Left-hand value
  • Comparator
  • Right-hand value

The left-hand and right-hand values can be either:

  • Variable reference
  • Variable attribute
  • Constant

Comparators

A comparator determines the type of comparison to be made between the left-hand and right-hand values.

There are six comparators:

EQ - Equal

The equal comparator, EQ, evaluates to true if both the left and right-hand values are equal to each other. If one or more of the values contains alpha characters (non-numeric), the comparison is case insensitive. That is, a word that is all lower case would be equal to the same word if it were all upper case (for example: dog would be equal to DOG).

The following are examples of if statements using the equal comparator, EQ:

NE - Not Equal

The not-equal comparator, NE, evaluates to true if the left-hand value is not the same as the right-hand value. As with the equal comparator, EQ, alpha character comparisons are case insensitive.

The following are examples of if statements using the not-equal comparator, NE:

LT - Less Than

The less than comparator, LT, evaluates to true if the left-hand value is less than the right-hand value. The less than comparator performs a numeric comparison.

The following are examples of if statements using the less than comparator:

GT - Greater Than

The greater than comparator, GT, evaluates to true if the left-hand value is greater than the right-hand value. As with the less than comparator, LT, the comparison is between two numeric values, as shown in this example:

LE - Less Than or Equal

The less than or equal comparator, LE, is similar to the less than comparator, LT, except that it evaluates to true if the left-hand value is less than or equal to the right-hand value, as shown in these examples:

GE - Greater Than or Equal

The greater than or equal comparator, GE, is similar to the greater than comparator, GT, except that it evaluates to true if the left-hand value is greater than or equal to the right-hand value, as shown in this example: