From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
05-02-2018 12:39 PM
This seems like a pretty simple thing, but maybe I'm missing something in the syntax.
I would like my while loop to be dependent upon two conditions, Here is what I have in the while loop condition field:
(Locals.ps_current < .6) || ((Seconds() - Local.StartTime) < 4)
Each of these statements work as expected when run on their own, but the OR (II) operator is not functioning as I would expect. The loop only ever exits after the first condition is fulfilled. Is it possible to have a while loop dependent on an OR statement like this?
Help?
05-02-2018 01:29 PM
What you have is correct. OR means that only one of the conditions has to be met. If you want it to exit if both conditions are met then use an AND (&&).
Hope this helps,
05-02-2018 01:32 PM
Thanks jigg, that's good to know, however it is not executing correctly. Only the first condition is evaluated but the second one is ignored. I have tried running each condition on it's own and the while loop exits as expected, but not when they are OR'd. Any ideas?
05-02-2018 01:43 PM
That's odd. I do this all the time. What if you put parenthesis around the entire statement?
05-02-2018 01:44 PM
In addition you could try the AnyOf function:
https://zone.ni.com/reference/en-XX/help/370052R-01/tsfundamentals/infotopics/anyof/
05-02-2018 02:14 PM
Oops... I was thinking of it wrong. I wanted the while loop to stop if either of the conditions were false, which is an AND not an OR.
Thanks for the heads up about the AnyOf function though, that's definitely something I'll use. thanks for your time, sorry!
05-03-2018 03:28 AM
AnyOf should work. Alternatively put brakets around the whole boolean logic. Point is that the expression has to evaluate to a boolean value. If one statement returns that, the next parts of the expression are ignored. In your case, the first part already evaluates to a boolean value hence the AND or OR logic is not taken into account.