LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a way to temporarily 'comment' out code in LV when trying to troubleshoot?

Solved!
Go to solution

Is there any way to comment out sections of LV code for debugging like there are in text based languages?

 

Thank you,

 

cayenne

0 Kudos
Message 1 of 3
(2,932 Views)
Solution
Accepted by topic author cayenne

Cayenne, there are a few really easy ways to do so:

 

Case Statement with a constant wired to it:  This is the simplest way to do this, just put a case statement on your block diagram and wire a constant to select the code you want to execute. 

 

Diagram Disable (as mentioned above):  You can find the diagram disable structure on the "structures" palette (the same place that you find for loops, while loops, etc.  When you drop the diagram disable structure on the block diagram, you'll see a selector at the top just like on a case statement.  However, in this case, you can select the "enabled" or "disabled" state.  Any code you place in the "disabled" state will be effectively commented out during execution.  You can right-click on a diagram disable structure and swap cases around just like with case statements, so this allows a bit of user-friendliness when enabling/disabling existing block diagram code.  Remember, however, that you still need to supply all the inputs and outputs to/from your code in BOTH cases of the diagram disable structure, unless there is a good reason not to!

 

"Conditional Disable": This is a little more sophisticated, but allows you a little more control of how your code gets executed.  (But you must be using LV Projects to use Conditional Disable structures.).  You'll find Conditional Disable structures again in the "structures" palette,  The conditional tests for these structures get defined under the "Project->Properties->Conditional Disable Symbols" menu option from either your project window menu or VI menu. You can find a good starting help article here for this topic.

 

Good luck and let us know how it goes!

 

 


--------------------------------------------------------------------------------------
Wes Ramm, Cyth UK
CLD, CPLI
Message 3 of 3
(2,913 Views)