LabVIEW Idea Exchange

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

Add "Replace with For Loop/While Loop" methods to VI Scripting

Status: New

You can right-click on a While Loop and select "Replace with For Loop", and vice-versa:

 

loops.png

 

Neither of these operations is currently available in VI Scripting. If they were, Quick Drop and other G-based editor features could benefit.

2 Comments
Darren
Proven Zealot

Interestingly, there is support in scripting for replacing Timed Loops and While Loops with each other.

Darin.K
Trusted Enthusiast

I have been doing this with the right-click framework since LV9.  I do not use the RCF any more but I tested the code in LV12 and it still works.  Adding the conditional terminals was easy, but the subdiagram labels are a bit of a trainwreck.  I'll have to hack around that.

 

Overall it was pretty easy to implement, about an hour (it would be less if I were the world's fastest LV programmer).

 

The native replacement would be nice, it is faster.  My scripting version breaks a ton of stuff and then fixes it, which I still enjoy watching in a weird sort of way.  There is that moment of anticipation when everything is broken, followed by relief.

 

But to be honest I do not support this idea as is.  I'd rather fix the native replacement to maintain wiring to the conditional terminals.  Then add the scripting support.

 

There is a comment in one of my VIs though: (edited for family viewing)

 

WHY THE F#$K IS THE LOOP COUNTER NOT INHERITED BY THE LOOP CLASS???!!!!

 

I was tired of casting to the specific loop type to get the reference.  The same could be said for the conditional terminal now that they all have one.  I would move it up the hierarchy and make it an error to write false to the While Loop HasCondTerm? property.  But I digress.

 

http://screencast.com/t/kmNIL4La