I'm looking for runtime optimizations and have the following problem, which I can't find any answer to in the documentation:
Let's assume, I have multiple conditions for an IF-statement, e.g.
var1 :=FALSE;var2 :=(whatever);IFvar1ANDvar2THEN
Β Β ; // some codeEND_IF
Is ```
var1 AND var2
evaluated in any case? or does it abort the evaluation as soon as it sees that
var1 = FALSE
```?
Reason: Before I evaluate a complex IF-condition (var2), I would like to pre-check, if this is necessary (var1). The second condition is expensive but is not required in 99% of the cases.
PS: Does anybody have a collection of such runtime optimization hints?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm looking for runtime optimizations and have the following problem, which I can't find any answer to in the documentation:
Let's assume, I have multiple conditions for an IF-statement, e.g.
Is ```
var1 AND var2
evaluated in any case? or does it abort the evaluation as soon as it sees that
var1 = FALSE
```?
Reason: Before I evaluate a complex IF-condition (var2), I would like to pre-check, if this is necessary (var1). The second condition is expensive but is not required in 99% of the cases.
PS: Does anybody have a collection of such runtime optimization hints?
Hi.
Use AND_THEN operator.
https://help.codesys.com/webapp/_cds_op ... n=3.5.15.0 m
Thanks a lot!
For the sake of completeness let's mention that for the OR statement there is also a corresponding OR_ELSE statement
+1 to list of FAQ of efficient runtime optimization in Codesys V3! Because the compiler is doing almost nothing in term of code efficiency...