This is only useful when the method returns some boolean.
To be honest I am personally not a huge fan of the AND_THEN extension as I dont need the AND_THEN that much. But this said, it available in the box of tricks
π
1
Last edit: hermsen 2022-04-08
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Please explain to me what is the difference between the following instructions :?
Can I use both interchangeably?
more posts ...
Yes. You'll suffer for multiple END_IFs in the second case.
No real difference when there's only one elsif statement, but consider what your code would look like if there was more than one
this:
is easier to understand and troubleshoot than this:
IF branching should be avoided by replacing it with a CASE statement if that is a possibility. But you probably know that π
Last edit: hermsen 2022-04-08
Just as hint: For reference/pointer/interface checks you could also use AND_THEN
This is only useful when the method returns some boolean.
To be honest I am personally not a huge fan of the AND_THEN extension as I dont need the AND_THEN that much. But this said, it available in the box of tricks
Last edit: hermsen 2022-04-08
To be honest, i love to pass a boolean as the return value for methods. Therefore i could simple call the method as a condition in IF statements.
the semicolon after END_IF has any meaning?
In CODESYS the IF is a statement. So the semicolon after the END_IF is needless. Only for assignment or calls is a semicolon required.