Hi all,
I am looking to re write this code more efficient and also allow me to have more than three fans.
Regards,
Code:VAR_INPUT Fan1 : BOOL; Fan2 : BOOL; Fan3 : BOOL; END_VAR VAR_OUTPUT OneFanRunning : BOOL; TwoFansRunning : BOOL; ThreeFansRunning : BOOL; END_VAR BEGIN // Three fans Running IF Fan1 AND Fan2 AND Fan3 THEN ThreeFansRunning := TRUE; ELSE ThreeFansRunning := FALSE; END_IF; // Two fans Running IF (Fan1 AND Fan2 OR Fan1 AND Fan3 OR Fan2 AND Fan3) AND NOT ThreeFansRunning THEN TwoFansRunning := TRUE; ELSE TwoFansRunning := FALSE; END_IF; // One fan Running IF (Fan1 OR Fan2 OR Fan3) AND NOT (ThreeFansRunning OR TwoFansRunning) THEN OneFanRunning := TRUE; ELSE OneFanRunning := FALSE; END_IF;
Last edited by WingedPanther; 04-25-2009 at 09:51 AM. Reason: add code tags (the # button)
That doesn't look like valid Pascal/Delphi code. That said, have you considered using an array?
You are right. Its not pascal. Its SCL Siemens step 7 which is based on Pascal.
I dont know much about arrays but I will look into. I will let you know how I get on.
Thanks
Why are you using SCL Siemens step 7 instead of Pascal, is it a script or something for another program?
In pascal to use an array would be like
I don't know if that is the same in the other languageCode:var Fans : Array[1..20] of Boolean; begin
To access the array value and set it
Hope it helps you.Code:Fans[2] := TRUE;
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks