Parenthesis ()

Top  Previous  Next

The brackets () are used in expressions to force a specific order of evaluation.

 

 

Example:

INCLUDE rtcu.inc
 
VAR
   a : INT; 
   b : INT;
END_VAR;
 
PROGRAM test;
 
BEGIN
   ...
   a := 2 + 3 * 4; // Result will be 14, as * (multiply) has higher priority that +
   a := (2 + 3) * 4; // Result will be 20 as the 2+3 is given highest priority because of the () brackets
   ...
END;
 
END_PROGRAM;