04-26-2016 09:19 AM
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 in LabVIEW can save you a lot of time.
These Conditional Disable 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 Structures 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 Structures 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.
Got a LabVIEW Tip of your own that you would like to share? Leave a message in the comments below or head over to our Facebook Page and leave us a message! If you would like to receive a new LabVIEW Tip each month directly to your inbox, follow this link to subscribe to our monthly newsletter!
The post LabVIEW Tip: Conditional Disable Structures appeared first on Austin Consultants.