09-10-2012 03:45 AM
I have a "while" loop running continuously, taking a measurement in each iteration. In each such iteration I save this single measurement to file AND display it on a graph. From time to time, I have "out-of-range" measurements, which are displayed as 1E-37 or 1E+37 on the graph and on file, and are irrelevant (to me, that is). Using a simple interpreter, such as python, I could use an "if" statement to check whether the reading is indeed irrelevant, and if so, "continue" the "while" loop so that it stops the current iteration and starts a new one.
How does one implement such a thing in LabVIEW?
Thank you,
Amit
Solved! Go to Solution.
09-10-2012 03:49 AM - edited 09-10-2012 03:51 AM
Hi Amit,
ever heard of a construct named "CASE structure"?
In LabVIEW that is the equivalent for things like "IF (out of range) THEN (do nothing)"...
Maybe it would help to take the free online LabVIEW courses offered by NI?
09-10-2012 03:51 AM
The cynicism is unnecessary.
Using the "case" structure is possible, of course, but that would require having it wrap the entire code inside the "while" loop. I was asking whether there was a simpler solution.
Amit
09-10-2012 03:58 AM - edited 09-10-2012 04:00 AM
Hi Amit,
there was no "cynicism", not at all! You are asking for some basic LabVIEW knowledge so I suggested where to get that...
"but that would require having it wrap the entire code inside the "while" loop."
Ok, then you should explain the difference to a IF/THEN construct in text-based languages. Does a simple
IF test
{ do something here}
ELSE
{ do something here}
not wrap code inside a structure?
A CASE structure does exactly the same and I don't see anything more simple than a compare function followed by two cases. What is complicated in drawing a case structure around some other code?
09-10-2012 04:01 AM
Very well. I guess that is good enough.
No pun intended.
Amit
07-19-2018 03:31 AM - edited 07-19-2018 03:43 AM
GerdW, I think you did not even understand the problem which Amit was trying to explain. I guess you need to attend at some programming courses yourself, in order to learn what the term "continue" means in a loop! Please stop being so arrogant!!
btw, back to the problem: if one wants to skip an iteration in a loop (or use a so called continue term in other programming languages, e.g. python), when a condition inside the loop is met, one can do it by right-clicking on the tunnel and choose "conditional" in the tunnel mode. The loop will skip the iteration and go to the next iteration, when the condition Boolean is turned to false.
the python equivalent of this would be:
for/while whatever:
if condition:
do whatever
else:
continue
07-19-2018 03:47 AM - edited 07-19-2018 03:50 AM
Hi Ood,
GerdW, I think you did not even understood the problem which Amit was trying to explain.
I think Amit and I agreed on speaking about the very same problem. He even accepted the solution…
back to the problem: if one wants to skip an iteration in a loop (or use a so called continue term in other programming languages, e.g. python), when a condition inside the loop is met, one can do it by right-clicking on the tunnel and choose "conditional" in the tunnel mode. The loop will skip the iteration and go to the next iteration, when the condition Boolean is turned to false.
You are 6 years late in this thread…
- The conditional tunnels didn't exist in LabVIEW at the time of the discussion, they just came with LV2012 in late autumn 2012.)
- When using a conditional tunnel you DON'T skip any iteration nor do you skip any code execution in the loop! (All you skip is appending the output to an autoindexed output array.)