Operator: <> (Not equal)

Top  Previous  Next

The <> operator compares two numbers or strings and returns TRUE if they are not equal.

 

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 <> b THEN
    // Will be executed if a is different from b
     ...
  END_IF;
  ...
  t := b <> 10; // t is TRUE if b is not equal to 10
  ...
END;
 
END_PROGRAM;

 

 

Example 2 :

 

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