LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
tbob

Extra For Loop Functionality

Status: Duplicate
See links to other idea conversations below.

The For Loop is one of the most widely used tools in Labview.  However, it has a drawback.  The step size and starting point is fixed and cannot be changed.  Most of the times this is OK.  But there comes a time when being able to change the starting index and/or the step size would become very useful.  Consider the following scenario:

 

You have a test results file as such:

Test1   UUT1   3.4

Test2   UUT1   4.5

Test3   UUT1   5.4

Test1   UUT2   3.0

Test2   UUT2   4.1

Test3   UUT2   5.2

Lets say you wish to extract all the info for Test2 only.

 

With a conventional For Loop, you would have to create special code to form the index.  You could do it with a While Loop:

 

21880i44C0BE7C265E7F7F  21884i11AA5440B1FB2F3A

 

 

Or you could have an option to specify the start, stop, and step parameters:

 

21886i75DF07FB2B0F1B67

 

This could be made possible as a right click option.  The default would be for the For loop to appear and function as it is now.  But if you right click on the border, you would get an option to display and use the extra terminals, as shown below.  This is similar to what is being done with the Conditional terminal.

 

21888iA08C0E5DE4D1CEFA

 

With this option, the three values would be supplied.  The i terminal value would follow the parameters.  With a start value of 1 and a step size of 2 and a stop value of 10, the i for each iteration would be 1,3,5,7,9.

This would also apply to auto indexing when this option is chosen.  In the above test result example. the code could be made even simpler by enabling indexing:

 

21890i2F764D51ADB4B1DF

 

If the start were set to 1, step to 3, and stop to 5 (or the length of the array - 1), the output would be rows 1 and 4.  No extra code needed.

 

I think this idea has great merits.  It allows use for special cases, and it allows the normal For Loop to be continued as it is today, making it backward compatible.

 

- tbob

Inventor of the WORM Global
11 Comments
JackDunaway
Trusted Enthusiast

@tbob wrote:

I don't think its fair that NI disabled the Kudos button because this was considered a duplicate idea.  Now this idea may never get through.  The part that is different than the other posting is that you can right click to add the additional terminals, otherwise its the same old For Loop that we have now.  So the idea really is not an exact duplicate.


Of all the "New For Loop" Ideas, I think this Idea closely matches the original Smart Iterators with Loops enough to consider it a Duplicate (that original Idea talked about hiding terminals in the comments section). Alex Pi, you can give Kudos to that Idea if you want the For Loop improved.