LabVIEW Idea Exchange

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

Real For Loop

Status: Duplicate
See additional idea conversations below

With text based languages, the For Loop has a programmable starting index, stopping index, and step size.  With Labview, the starting index is always zero and the step size is always 1.  It is not changeable.  I would like to see Labview have a real For Loop where there would be three terminals inside the For Loop that can be set by the user.  One terminal for initial value (starting index), one for final value (stopping index), and one for step size.  This would be of great value to all Labview programmers.  Of course the terminals can be much smaller than what is displayed in the picture.  One or two letter terminals, such as ST for start, SP for stop, and SZ for step size would do fine.  (or N for initial value, F for fnal value, and S for step size).  The real for loop should be capable of going in a negative direction, like starting at 10, ending at -10, with a step size of -2.

 

 

21077i3760182794779C02

- tbob

Inventor of the WORM Global
38 Comments
tbob
Trusted Enthusiast

If we keep pushing the idea, maybe NI will finally do it.

- tbob

Inventor of the WORM Global
TCPlomp
Trusted Enthusiast

Please don't. Not more options/text for the for loop...

 

Ton

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
JackDunaway
Trusted Enthusiast


tbob wrote:

If we keep pushing the idea, maybe NI will finally do it.


I made a similar comment about this very idea. It is not the highest Kudoed Idea, but it's the most independently requested Idea.

 

Perhaps, R&D

Finds G For Loop Deficient.

Commence new feature!

JackDunaway
Trusted Enthusiast

@TCPlomp wrote:

Please don't. Not more options/text for the for loop...


Could you make an argument why not? I love this idea, and don't see any reason why not to implement it. I agree the text should not be text (translation SNAFU, BD real estate hog...), but rather a distinguishable icon, but other than that, what's wrong with this Idea?

tbob
Trusted Enthusiast

If you read my description, you will see that the text was added for illustration only.  The text could be made into icons.  There is an N icon now.  Adding two more small icons would not significantly increase the real estate usage.  Most For Loop implementations are usually plenty large enough to handle two more small icons.  As an alternative, the N icon could be made to accept a cluster (start, stop, step size), a three element array, or even a comma delimited string containing 3 numbers.

 

This new For Loop could be in addition to the traditional For Loop so users would have a choice.

 

Another idea would be to use the traditional For Loop as a starting point, and then right click on the border to show the 3 icons instead of the N.  We do this now to create a break terminal.  That gives us all a choice as to how we want to use the For Loop.  There simply is no reason why we can't all have our way.  This idea would make it possible.

 

The idea has been posted in the past, and no action was taken.  Lets push this one through.  Having the option to use the new loop or the traditional one is a very valid reason to vote for this idea.

 

- tbob

Inventor of the WORM Global
JackDunaway
Trusted Enthusiast


tbob wrote:

As an alternative, the N icon could be made to accept a cluster (start, stop, step size), a three element array, or even a comma delimited string containing 3 numbers.

 

This new For Loop could be in addition to the traditional For Loop so users would have a choice.


1. I really don't like the idea of having two For Loops. There should only be one For Loop implementation in the G language. Otherwise, you're deepening the divide in echelons of programmers (e.g., the "Beginner", or even worse, "Express" For Loop and the "Advanced" For Loop)

2. I'm not a fan of clustered or string inputs for loop parameters. There are four parameters available (Start, Step, Stop, Iterations), of which any three can fully constrain the For Loop execution. You should be able to choose any combination that constrains the loop, and each parameter should be an icon the same size as the "N" square terminal with which we are familiar. The problem with Clustered inputs is the "Parameters" input of the For Loop would need to be polymorphic over several different input combinations, especially confusing if the programmer decides to hide the labels on the cluster elements. The problem with the string input is we're too far into the dark side on the "G vs Text spectrum".

tbob
Trusted Enthusiast

I agree that there should be one For Loop with 3 terminals.  I was just throwing out alternatives.  Actually, I didn't like any alternative either.  I should not have even brought them up.  A For Loop with 3 terminals would be best.

 

What about the idea about clicking on the border to choose from the one N terminal with a fixed step size of 1 and the newly proposed 3 terminal version?  This would at least make it backward compatible.  Something to think about.

- tbob

Inventor of the WORM Global
JackDunaway
Trusted Enthusiast

Yes, currently two of the three parameters are implicit (Step=1, Start=0) where Iterations is explicitly wired (or implicitly determined based on the auto-indexed array with fewest elements). I envision a For Loop that has either zero, one (current implementation), two, or three terminals showing out of an available four terminals (Start, Step, Stop, Iterations). If you have zero, one, or two terminals wired, the other terminals are implicit. If the For Loop is overcontrained or underconstrained, the VI is broken.

tbob
Trusted Enthusiast

So you would right click on the border to select which terminals would be shown.  Terminal not shown would be implicit.  Great idea.  This way, it would be backward compatible, and the auto-indexing would still be available.  This is the best idea yet.

 

- tbob

Inventor of the WORM Global