BEGIN

Top  Previous  Next

BEGIN starts a section of code that will be executed repeatedly. The code between BEGIN and END will be executed until an EXIT statement is reached. If no EXIT statement is reached, the code will keep executing indefinitely. During each iteration, a call to UPDATEIO will be done to update all physical in- and outputs. Typically in a VPL program, one main loop will keep executing indefinitely and make the necessary calls to functions and function blocks. The BEGIN/END construction is only allowed in the program section.

 

 

Example:

INCLUDE rtcu.inc
 
VAR
  a   : INT;
  b   : INT;
  str : STRING;
END_VAR;
 
PROGRAM test;
 
// Code from this point to END are executed forever
BEGIN
 
  IF a > b THEN
     str := "a is grater than b";
  ELSIF a = b THEN
     str := "a equals b";
  ELSE
     str := "a is lesser than b";
  END_IF;
 
END;
 
END_PROGRAM;