How to evaluate if an integer value is odd or even in Step7 SCL

I Thought I did ???

If i write like this I can't compile

Code:
ELSIF INT_TO_BOOL(index)
But if I use this, It compiles

Code:
ELSE IF INT_TO_BOOL(index)

What error did it give?

Code:
IF condition
THEN
    stuff;
ELSIF condition2
THEN
    otherstuff;
ELSE
    stuff if not any of above conditions is met;
END_IF;
Above is elsif structure. Below will be what u wrote, that is two nested if's.

Code:
IF condition
THEN
    stuff;
ELSE
    IF condition2
    THEN
        otherstuff;
    ELSE
        stuff if not any of above conditions is met;
    END_IF;
END_IF;
In this case it works the same, but its matter of "good code". Also in good programming practice is indentation to show "level" of instructions as shown above. It results in better readability of code.
 
Last edited:
Sorry, I forgot to remove the last "end_if", what happen the first 2 or 3 times I don't know, but now it compiles.
 

Similar Topics

Hi there, I have never used Citect before and have a few bugs to fix. I have 2 questions: 1. How can i view the tag database as a whole...
Replies
10
Views
3,449
Does anyone know how to do this logic in Contrologix?
Replies
3
Views
1,570
Hi all, I'd like to know your point of view on this aspect of PLC programming, the example I use is simple, but the concept can be applied to...
Replies
5
Views
2,473
Hello I need to know how many input are true from at 5-bit pattern. The True/False sequence is random. The evaluation has to be in every scan...
Replies
3
Views
1,686
Hello, I wrote some vba code for a Factorytalk View Studio SE application display. The code should be around 100 lines long using something...
Replies
2
Views
1,964
Back
Top Bottom