LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a way to 'comment' out code?

Frequently, I write bad code.... Its a fact of life for me.  Usually I have to try three or four iterations of a subVI  to get it to work just the way I like it.  SOmetime I wish that there was a way that I could highlight sections of code and click a button to temporarily disable it, while I work on other sections of code.  Is there a simple way to do this?  (apart from working on a copy, putting it in a case structure, so on...)  All I want is to be able to drag and click and have it commented....
 
Grub
Hell, there are no rules here...we're trying to accomplish something!!! - Thomas Edison
0 Kudos
Message 1 of 39
(7,009 Views)
The only way I do it is to wrap the code I don't want executed into a case structure that is set to false.  If you want to remove the "comment", make sure your original code is shown before removing the case structure.
0 Kudos
Message 2 of 39
(6,986 Views)
As tuned99 said.
 
Use a Case Statement.  You can also wire a switch instead of a fixed boolean.  The switch can be called "ByPass ThisCode".
It is the LV way to comment out code.  The Case Statement then becomes your friend 😉
 
Actually, you can eventually use the "newly" created Case Statement to turn that portion of code to a sub-vi in the future... which is why I use the switch.  You'll notice that it will eventually help to keep the vi clean.
 
JLV
Message 3 of 39
(6,970 Views)

The problem with commenting with a case structure is that your code, even code that never gets executed, has to be executable.  You can't have inclompletely wired items, or broken wires even if  the code will never be used.  So it's not really a comment, but a conditional branch that never branches. 

 

Sheldon

Message Edited by Support on 08-23-2005 08:02 PM

Technical geek, engineer, research scientist, biodegradable...
Message 4 of 39
(6,932 Views)
sweet....
Hell, there are no rules here...we're trying to accomplish something!!! - Thomas Edison
0 Kudos
Message 5 of 39
(6,925 Views)
There's always the conditional disable structure from the PDA module, which can be found in the LAVA forums. I think they warn it may crash standard LV.

___________________
Try to take over the world!
Message 6 of 39
(6,912 Views)
If anyone wants this conditional disable, here it is.  The instructions on the front panel were not quite right.  I put the vi in my user.lib folder, and edited my palette view to include it there.  Then you have to open a vi that you want some code disabled, and also open the disable vi.  Go to the block diagram of the disable vi and copy the structure to your regular vi.  Then you can move some code that you want "commented out" into the disable structure.  This causes broken wires that you have to fix.  In my opinion, you are better off creating a case structure and wiring a false constant.
- tbob

Inventor of the WORM Global
Message 7 of 39
(6,910 Views)

Hello!

 

 

I am really excited to inform everyone that National Instruments announced LabVIEW 8.0 yesterday.

 

One of the new and highly requested features of 'commenting' out code is now native in LabVIEW 8.0.

 

For additional information please visit the following links to learn more about LabVIEW 8.0.

 

 

 

 

 

LabVIEW webpage

 

www.ni.com/labview

 

 

 

Regards,

 

Somendra

 

 

Applications Engineering

 

 

National Instruments

0 Kudos
Message 8 of 39
(6,784 Views)
If you upgrade to LV 8, you would get conditional structure. This is a true commenting out part of code rather than wiring false to a case structure.

0 Kudos
Message 9 of 39
(6,771 Views)
Hola Otoro,
 
By "true commenting out part of code" do you mean it wouldn't load the code, e.g., Sub VIs, into memory either? 
 
Don't have 8.0 yet to try it myself.
 
Thanks,
 
-Khalid
 
0 Kudos
Message 10 of 39
(6,737 Views)