LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Article - LabVIEW 8.5 Feature - For Loop Conditional Terminal

[cross-post]

Hi All,

I've written an article about a new feature in LabVIEW 8.5 that I think is really useful.
As usual, your feedback is most welcome smile.gif

Thanks,

-Jim
Message 1 of 15
(4,891 Views)

Excellent article Jim,

It's one of those features that I am starting to adopt, so it's good to be reminded of it.

Just one comment about the article.  You're missing the word "see" in the text below:

"In the screenshot below, you can the difference between the classic For Loop and one with a Conditional Terminal."

                                              ^see^



Message Edited by JoeLabView on 07-07-2008 11:59 AM
0 Kudos
Message 2 of 15
(4,871 Views)


@JoeLabView wrote:

Excellent article Jim,

It's one of those features that I am starting to adopt, so it's good to be reminded of it.

Just one comment about the article.  You're missing the word "see" in the text below:

"In the screenshot below, you can the difference between the classic For Loop and one with a Conditional Terminal."

                                              ^see^



Hi JLV,

Thanks for the feedback and for your attention to detail!  Sometimes my brain gets ahead of my fingers 🙂

Yes, I really love this feature and have finally started to use it regularly.  Now that I am, I can't imagine life without it.

Cheers,

-Jim
Message 3 of 15
(4,866 Views)

@Jim Kring wrote:

Yes, I really love this feature and have finally started to use it regularly.  Now that I am, I can't imagine life without it.

I can. I'm still at 8.2. Smiley Very Happy
0 Kudos
Message 4 of 15
(4,816 Views)


@smercurio_fc wrote:

@Jim Kring wrote:

Yes, I really love this feature and have finally started to use it regularly.  Now that I am, I can't imagine life without it.

I can. I'm still at 8.2. Smiley Very Happy



I have to switch between 8.5 and 8.2 and whenever I have to use 8.2, I'm disappointed when I can't find this feature 😞
0 Kudos
Message 5 of 15
(4,811 Views)
Nice Article...reminds me of the nuggets you see on the forums.
 
I like the file delete example.  I had a flashback to when I first learned batch files in DOS. In the course of minutes I managed to rename every file in my C: drive:)  Luckily I had and image backup but very powerful stuff.
 
A hybrid conditional FOR loops...just another good reason for using auto indexing.
 
Thanks,
 
-SS
 


0 Kudos
Message 6 of 15
(4,804 Views)
Thank you Jim for one more interesting article.

My humble suggestion would be to complete the article by adding an example that shows the differences between a
for loop with conditional terminal and a while loop (--> no need to extract the array size and to compare it with the loop index to stop after the last element of the array).




Message Edité par JB le 07-08-2008 08:47 AM
0 Kudos
Message 7 of 15
(4,773 Views)
JB, you should note that this fails to account for the empty array case. To properly simulate the FLwB, you need to wrap the while loop in a case structure and only execute it if the array is not empty.

___________________
Try to take over the world!
0 Kudos
Message 8 of 15
(4,763 Views)


@JB wrote:
Thank you Jim for one more interesting article.

My humble suggestion would be to complete the article by adding an example that shows the differences between a
for loop with conditional terminal and a while loop (--> no need to extract the array size and to compare it with the loop index to stop after the last element of the array).




Message Edité par JB le 07-08-2008 08:47 AM

I'm glad you found the article interesting 🙂

And, thanks for the suggestion -- there is certainly value in seeing the For Loop and While Loop implementations side-by-side, although they are not equivalent when the input array is empty (as using a While Loop to iterate over an ordered set gets complicated/ugly when we try to iterate over empty sets):

First, there is a bug in your upper loop: The decrement operation could cause the While Loop could execute infinitely, since the array length is zero and 0 -1 = -1 which is always less than (i.e., never equal) to i (which starts at 0 and increments on each iteration of the loop).  This is easily fixed by removing the decrement 😉

Second, the While Loop implementation would output a TRUE if the random number passed into the loop were 0, which is the default value of integers (the input array type).

For my article, what I really wanted to highlight is how a For Loop can behave more like a While Loop rather than the inverse.  For example, a For Loop is really a specialized While Loop that is optimized for iterating over ordered sets (iterating a pre-determined number of times is a For Loop's raison d'etre).  The Conditional Terminal allows one to conveniently break, should an exceptional condition occur while iterating over an ordered set.

Cheers,

-Jim
0 Kudos
Message 9 of 15
(4,760 Views)
Hi,
Good Article - I'm just starting to use these.

Just one comment:
The two for loops in Example 2 - searching an array -  will give different outputs if there is more than 1 match in the array. The first will give the index of the last matched element and the second will give the first matched element.

Dave

0 Kudos
Message 10 of 15
(4,747 Views)