LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
Darin.K

Reverse Iteration Terminal in For Loop

Status: New

It has been a few months since a suggestion has been made to do something about the For Loop, so if nothing else it is time to stir things up a little bit.  There have been several suggestions to do something with the iterators, for example:

 

http://forums.ni.com/t5/LabVIEW-Idea-Exchange/Smart-Iterators-with-Loops/idi-p/967321

 

http://forums.ni.com/t5/LabVIEW-Idea-Exchange/for-loop-increment/idi-p/1097818

 

http://forums.ni.com/t5/LabVIEW-Idea-Exchange/quot-Start-Step-Stop-quot-structure-on-For-loops/idi-p...

 

None of these has really gained traction, and heck, I haven't settled on any of them myself.  In most cases I am satisfied with a workaround, usually involving the Ramp VI.

 

There is one case where I am not happy with the workaround.  I happen to need reverse iteration values quite often (N-1,N-2,...0).  With the N terminal pinned to the top-left corner I have little choice but to do the following and start zigging and zagging wires:

 

18391iB5AE9450400CAAD6

 

I would simply like a reverse iteration terminal which can be moved around at will and simply counts down.  Doesn't have to look like I have drawn it, that just happens to be intuitive to me.  Naturally this terminal (and the normal iteration terminal) should have the option to be hidden.

 

I thought about having the option to have the loop spin backwards, similar to reversing all auto-indexing inputs and having the iteration terminal count down, but I just could not decide what to do about auto-indexed outputs.  My G-instincts tell me that they should be built in the order of loop cycles, my C-instincts tell me I am building array[i] and if i goes in reverse order, so should the array elements.  For now I say, forget it, and just stick to the simple terminal.  Array reversal is essentially free, so I at least have a workaround there.

37 Comments
Darin.K
Trusted Enthusiast

One goal is certainly to percolate more For Loop discussions.

 

For this simple idea, nothing fundamental changes.  Start-Stop-Step-N and whatever else settles is also nice (and should be mentioned in the threads I linked).

 

THEY ARE NOT MUTUALLY INCLUSIVE OR EXCLUSIVE

 

I want to autoindex and have reverse iterations.  Setting Start-Stop-Step means I would have to start doing math with the array length to get to the same place I am looking for.

 

I want it all, but this is the very least.

JackDunaway
Trusted Enthusiast

I have transitioned our discussion about "Start, Stop, Step, N" to the more appropriate comments section of Smart Iterators with Loops.

JackDunaway
Trusted Enthusiast

@Darin.K wrote:

I want to autoindex and have reverse iterations.  Setting Start-Stop-Step means I would have to start doing math with the array length to get to the same place I am looking for.


Autoindexing: most of my auto-indexed loops don't even use the Iteration or Count Terminals (hence). The loops I autoindex and the loops I would want to use the Start-Stop-Step-N are virtually mutually exclusive. Related, virtually all of my auto-indexed loops are parallelizable - no data or control dependencies between iterations. That being said, autoindex the array forwards, backwards, it doesn't really matter most the time.

 

***EDIT: Re-reading my comment, I'm just pointing out that auto-indexing does not carry much consideration of these "enhanced control for loops". I speak for myself. ***

PJM_Labview
Active Participant

I think the "N - 1 - i" is interesting.

 

Maybe one could click on the "i" terminal and edit what computation is done there.

Available variable would be N; i, and any number.

Available operation would be +,-,*,/ (not sure about divide though).

Once the editing is done the "i" would change to (for instance) "N-1-i"

 

PJM



  


vipm.io | jki.net

altenbach
Knight of NI

> Maybe one could click on the "i" terminal and edit what computation is done there.

 

Interesting idea!

 

It could look as it is now, but we could edit the "i", exactly like an expression node, right there on the diagram. I think division should be allowed, especially if orange datatypes are allowed. (representation could be set by right-clicking). All syntax, operators, and functions of an expression node should be allowed. The only difference is that it has no input connector, the input is fixed to [i]

 

(I would not like an express VI type configuration that hides the code).

AristosQueue (NI)
NI Employee (retired)

> It could look as it is now, but we could edit the "i",

> exactly like an expression node, right there on the diagram

 

If it looks just like it does now, it would be hidden functionality -- most people wouldn't know you could click on it to edit. Further, you haven't saved much of anything ... you might as well just drop an Expression Node directly. It would need magical syntax access not just to i but also to N (just to handle the obvious count down case), it wouldn't be further parameterizable, etc.

 

Sorry, I don't like this variant.

Intaris
Proven Zealot

I'm glad AQ said he's against it because now I don't have to.  (I don't like the expression node idea at all).

 

K.I.S.S.

 

I would prefer to have BOTH i and N-i-1 or whatever it ends up being called available so I'd be against an ability to switch between the two versions.  Sometimes it's just useful to have both.

altenbach
Knight of NI

Yes, you are right. It would need a few predefined variables (i, N, etc. ... ).

 

I still like the direct (='expression node" style) editing. 😉

 

One thing is also that many times we need more than one output, so it could even be vertically resizable to enter multiple expressions for multiple outputs. Probably overkill, just thinking out loud. 😮

 

i+1

N-i-1

2i²+3i

Intaris
Proven Zealot

I would be for the expression noide option ONLY if the expression is always visible.

 

But I have a feeling this would kill a bit of screen real-estate.

 

I actually like the vertically resizeable idea.

 

PS What would be the "etc." predefinied variable??  Are there any valid variables except "i" and "N"?

altenbach
Knight of NI

> Are there any valid variables except "i" and "N"?

 

A pet variable of mine (that is not available :() is the parallel instance for parallel loops. 😉