Introduction
Modular programming helps break big programs into smaller parts. This makes programs easier to understand, fix, and reuse.
MODULE ModuleName // Your code here END_MODULE
MODULE MotorControl
// Code to start and stop motor
END_MODULEMODULE SensorRead // Code to read sensor values END_MODULE
MODULE MainProgram
VAR
motorOn: BOOL := FALSE;
END_VAR
// Turn motor on
motorOn := TRUE;
END_MODULEResult after execution?FUNCTION AddTwoNumbers : INT VAR_INPUT a : INT; b : INT; END_VAR AddTwoNumbers := a + b; END_FUNCTION PROGRAM Main VAR Result : INT; END_VAR Result := AddTwoNumbers(3, 4); END_PROGRAM
FUNCTION Multiply : INT VAR_INPUT x : INT; y : INT; END_VAR Multiply := x * y END_FUNCTION
Pass the test and this pattern moves unknown