Operator: < and > (Less than, Greater than)

Top  Previous  Next

The < operator compares two numbers or strings and returns TRUE if the left expression is smaller than the right expression.

The > operator compares two numbers or strings and returns TRUE if the left expression is greater than the right expression.

 

The comparison is case-sensitive.

See example 2 below.

 

 


Example 1:

 

INCLUDE rtcu.inc
 
VAR
   a : INT; 
   b : INT;
   t : BOOL;
END_VAR;
 
PROGRAM test;
 
BEGIN
   ...
   IF a THEN
      // Will be executed if a is greater than b
      ...
   END_IF;
   ...
   IF a < b THEN
      // Will be executed if a is lesser than b
      ...
   END_IF;
   ...
   t := b 10; // t is TRUE if b is lesser than 10
   ...
END;
 
END_PROGRAM;

 

 

Example 2 :

 

INCLUDE rtcu.inc
 
VAR
   a : STRING := "Peter";
   b : STRING := "Jack";
   t BOOL;
END_VAR;
 
PROGRAM test;
 
BEGIN
   ...
   IF a < b THEN
      // Will not be executed as "Peter" is not less than "Jack"
      ...
   END_IF;
   ...
   t := a b; // t will be TRUE as "Peter" > "Jack"
   ...
END;
 
END_PROGRAM;