05-08-2025 05:42 PM
Hello all,
I have a situation with a VI that I'm working on. I hope someone can help me clarify my doubts or review my case. My VI consists of the following:
I have two rows and three columns of listboxes, each listbox displays different texts that are read from a text file:
In each listbox I have an option to add more options or remove some of the options:
I also have the function to delete a complete row
Each sample has a color depending on the file being read; in this case, I have three files. Each file contains different options, so if any data is read that corresponds to one of the three files, it is assigned a different color. This is the structure of the diagram:
I can also save all these modifications. Structure of the case event:
Everything works fine. My problem arises when I need to add a new function. This function adds three buttons to the screen, each of which opens a new file containing a different mix of options to be read:
Since these are buttons, I am trying to run a event case for reading each file but because the values are read before the loop, I'm placing the event case outside the loop. Is this possible? Every time I run it, it only lets me open one file, but then the VI crashes when I click on another button:
Attached both VI.
Does anyone know how I can fix this? Thank you.
05-08-2025 07:27 PM
You need to implement a proper state machine. An event structure on the top-level diagram can run exactly once per session. Since all your events lock the panel, any later triggering of any of the event will lock up the VI forever.
The concept of "dataflow" is central to any LabVIEW program, so make sure you fully understand it.
05-09-2025 02:48 AM
To help you on your way: Place a single while loop, in the while loop, place a single case structure. On the default case, place a single Event structure. When a user event happens (a user clicks on a button for example), an event fires and it passes the state to the next iteration of the while loop, where the actual logic of that event happens (don't place any code in the event structure itself!).
Here is the most basic state machine as an example.
If you need a more complex logic, have a look at the JKI state machine for a more complete template.