- Posted on: 2021-01-20
LabVIEW is a great programming environment for test and control systems but it can be challenging for beginners to keep the code visually clean, especially as quick tests and validations are added.
Symplify templates are based on a Case Structure inside a While Loop, akin to a “State Machine” (NI Link) or a Producer/Consumer (NI Link) bundled inside the same loop. As such, there is no inherent limit to the number of cases that can be added within the code or the naming of those:
When you want to try another version of your code, right-click on the case name and select “Duplicate”.
Just name that case something like “Backup original logic – 2020-11-15” and leave it untouched. As you complete changes in the original case, it’s simple to swap the names to run the original code and compare performance and results (read this blog post about modifying a single VI while application is running).
You can even repeat this more than once, creating a few similar cases while retaining the other “versions” of the logic untouched! Our clients and developers find this to be a very natural way to progress and try things out without relying on “Undo”.
Two things to keep in mind:
When using this, (the) trick is to replace actual Controls and Indicators by Local Variable. Otherwise, a new copy of each control/indicator is created in the new case.
Always add some quick comments about what you are trying to achieve. When the issue is solved, most developers don’t revisit the code to clean things up so the notes are already there for the future.
Benefits
As we stated in the introduction, this approach really helps keep the code clean and fit within a single screen. Also, unlike a “Diagram Disable Structure”, it is actually possible to decide which version of the code to execute at run-time. For example, the case “Parse Values” may be significantly faster to search for an entry but “Parse and Sort Values” be required at times to support user interaction.
This trick should work with many other VI architectures.