Closed Thread
Results 1 to 4 of 4

Thread: More efficient way to write pascal programme

  1. #1
    wahsbg is offline Newbie
    Join Date
    Apr 2009
    Posts
    2
    Rep Power
    0

    More efficient way to write pascal programme

    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)

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Join Date
    Jul 2006
    Posts
    16,491
    Blog Entries
    75
    Rep Power
    143

    Re: More efficient way to write pascal programme

    That doesn't look like valid Pascal/Delphi code. That said, have you considered using an array?
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  4. #3
    wahsbg is offline Newbie
    Join Date
    Apr 2009
    Posts
    2
    Rep Power
    0

    Smile Re: More efficient way to write pascal programme

    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

  5. #4
    gasdeveloper is offline Newbie
    Join Date
    Jan 2009
    Location
    California, USA
    Posts
    2
    Rep Power
    0

    Re: More efficient way to write pascal programme

    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
    Code:
    var
        Fans : Array[1..20] of Boolean;
    
    begin
    I don't know if that is the same in the other language

    To access the array value and set it
    Code:
    Fans[2] := TRUE;
    Hope it helps you.

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Programme operation and speed
    By sb001 in forum General Programming
    Replies: 2
    Last Post: 04-26-2011, 10:47 PM
  2. Odd / Even Programme in C#...Please Help,Help,Help.
    By umair10 in forum C# Programming
    Replies: 7
    Last Post: 07-01-2010, 09:13 AM
  3. help wid a programme
    By lionaneesh in forum C and C++
    Replies: 2
    Last Post: 03-23-2010, 02:07 PM
  4. uploading a programme on the web
    By kenex in forum Website Design
    Replies: 3
    Last Post: 12-10-2008, 02:53 AM
  5. Help With Sysmetrics Programme
    By bodhi2016 in forum C and C++
    Replies: 1
    Last Post: 04-28-2008, 06:05 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts