LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Interest to use a While Loop and stop it at the first iteration

Hello,

Here is a little technique that I don't get.

A subVI is using a while loop, a TCP connection is opened, and then TCP write and TCP read are used once.

After that, if there is an error or connection or if the indice of iteration is different of 0, the while loop is stopped.

My question is:

Why is it necessary to use a while loop? With nothing, it would be ok? the subVI is executed one time and that's all, no?

Thanks for your help.


0 Kudos
Message 1 of 4
(2,851 Views)
Are there any uninitialized shift registers on the loop? If not, I would tend to agree with you that the loop is unnecessary - though it's hard to say without seeing the entirety of the loop's code and where it occurs. I'm assuming from the tone of your post that this is inherited code. Something else to consider is that there may have been a point in time when the loop needed to be executed more than once and what you are seeing now is an artifact of that.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 4
(2,844 Views)
Yes this is most likely a loop for using a functional global (uninitialized shift registers).  This register will keep track of the last value from call to call and is a very important concept in labview. It essentially gives a vi some level of persistance from call to call.
Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 3 of 4
(2,810 Views)

What a silly little piece of code. Believe me, I don't get it either. Looks like a beginners construct, so don't take it too seriously. Where diid you find this?

Analysis:

Since you were talking about stopping a while loop at iteration=0, I assume that the bottom-right boolean output leads to the conditional terminal of the loop set to "stop if true". Is this correct?

  • Since the loop will stop after the first iteration due to i=0 (there is actually a primitive "=0" that could be used to simplify the code), all the other ORs are not needed at all and just complicate the code.
  • The "compound OR" could have been resized to take all three inputs, eliminating the first OR
  • Why would the error out go to a local variable instead of a terminal?

Overall, there's not much more than can be said about such a disconnected and isolated code fragment. Please post a full picture or the entire subVI for further analysis.

0 Kudos
Message 4 of 4
(2,798 Views)