From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

London LabVIEW User Group

cancel
Showing results for 
Search instead for 
Did you mean: 

Conditional Disable Structure Tips

Ever find yourself adding a lot of changes to your code for testing that you may need to roll back to their previous states? Using Conditional Disable Structures can save you a lot of time.

These Structures allow you to disable a piece of code and set up a condition for which case it should select. This can be very useful when making a lot of changes to different VI’s within your project.

To set up the Condition, first you must open the Conditional Disable Symbols page which can be found by selecting Project>Properties from your Project Explorer. The Project Properties screen will appear with a set of categories down the left. Select Conditional Disable Symbols to find the following page.

 

Here you can add a new Symbol and set it a value. You may wish to set the Symbol as the date in which this update takes place such as 01_01_15 for the First of January 2015. The Value can be set to anything but for demonstration we will use TRUE.

After setting a Symbol you can now create a Conditional Disable Structure. Open a VI in which you wish to add the Structure and navigate to the Block Diagram. Open the Functions Palette and select Programming>Structures>Conditional Disable Structure. Drag over the code you wish to disable and release. You should now have a Conditional Disable Structure with one case. If you right click on the case and select either Add Sub diagram Before or Add Sub diagram After, the following pop up appears.

Here you can configure your condition. By selecting the down arrow under Symbol(s) you should be able to see the Symbol we created earlier (01_01_15). If you leave the second drop down as == this will mean the case will equal the value of Value(s). Enter the value TRUE for Value(s) and select OK. This will now give you a new case in which the header should read 01_01_15==TRUE. This means this case is now active and the code within this case will run. This method can be used as many times as possible within one VI or multiple VI’s within the project.

If you ever need to roll back the changes, instead of going into every VI and making changes, you can simply go back to the Conditional Disable Symbol page and change the Value of the Symbol you wish to change. So in this case we would change the Value of 01_01_15 from TRUE to FALSE. This would mean the default case would then be ran within your VI.

**BONUS**
You can have more than one condition in your Conditional Disable Structure, so if a new update is required you can add this into your structure and this means you can always roll back to the previous versions.

The post Conditional Disable Structure Tips appeared first on Austin Consultants.

0 Kudos
Message 1 of 1
(3,849 Views)