| Pat McCarthy |
19-07-2011 23:02 |
Help needed with RSLogix 5000
Hi! I'm hoping there is someone out in the CD community who has some experience using Structured Text with RSLogix 5000.
Using a variety of sources, I am unable to determine what I am doing wrong with the syntax of my code.
When I verify the code shown below, I receive the following errors:
Error: Line 2: Keyword "END_IF" expected
Error: Line 29: Unexpected end of text found
Code:
// If no rows have only 1 light...
if ((ROW1_Value <> 1) AND (ROW2_Value <> 1) AND (ROW3_Value <> 1)) then
if (ROW2_Value > 0) then ROW2_Value := 1; // Then check for the first row
elsif (ROW1_Value > 0) then ROW1_Value := 1; // to have greater than 0 and set it to 1
else ROW3_Value := 1; end_if;
// Else if only one row has 1 light left...
elsif((ROW1_Value = 1) XOR (ROW2_Value = 1) XOR (ROW3_Value = 1)) then // XOR to check for only 1 row having 1 light left.
if((ROW1_Value = 1) AND (ROW2_Value >= 0) AND (ROW3_Value >= 0)) then // First possibility
if(ROW2_Value >= 2) then ROW2_Value := 0;
else ROW3_Value := 0; end_if;
elsif((ROW1_Value >= 0) AND (ROW2_Value = 1) AND (ROW3_Value >= 0)) then // Second possibility
if(ROW1_Value >= 2) then ROW1_Value := 0;
else ROW3_Value := 0; end_if;
elsif((ROW1_Value >= 0) AND (ROW2_Value >= 0) AND (ROW3_Value = 1)) then // Third possibility
if(ROW2_Value >= 2) then ROW2_Value := 0;
else ROW3_Value := 0; end_if;
// Else if two rows have only 1 light left...
elsif( ((ROW1_Value = 1) AND (ROW2_Value = 1)) OR ((ROW1_Value = 1) AND (ROW3_Value = 1)) OR ((ROW2_Value = 1) AND (ROW3_Value = 1)) ) then
if((ROW1_Value = 1) AND (ROW2_Value = 1)) then ROW1_Value := 0;
elsif((ROW1_Value = 1) AND (ROW3_Value = 1)) then ROW3_Value := 0;
else ROW2_Value := 0; end_if;
// Else if all three rows have 1 light left...
else ROW2_Value := 0;
end_if;
|