Rasmus7700
(Rasmus Balle)
November 16, 2016, 7:41pm
1
Hello Guys…
Is it possible to exit a loop if the initial conditions isn’t met?
meaning if the while loop looks like this:
while( (value 1.state as DecimalType < value2.state as DecimalType))
and i wanna exit it before the above statement is true with a switch?
rlkoshak
(Rich Koshak)
November 16, 2016, 7:59pm
2
I don’t understand the question.
But a while loop can have || and && clauses like any if statement so do you mean something like this?
var boolean exitFlag = false
while( (value1.state as DecimalType < value2.state as DecimalType) && !exitFlag) {
...
if(some condition) {
exitFlag = true
}
}
1 Like
Rasmus7700
(Rasmus Balle)
November 16, 2016, 8:34pm
3
Thanks… exactly what I needed… in my plc world I need to do something like if … then exit…
thanks
Sorry for the dumb question - but what is the ll? Or?
Benjy
(Ben Clark)
November 16, 2016, 10:06pm
4
Yes, || means a logical or, there’s usually a place for the vertical bar “|” (aka a “pipe”) on the keyboard but if you own one from one of the few countries that don’t have it, then you can hold alt and press 124 on the keypad to get it.