From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
08-27-2020 04:56 AM
Hi all,
Currently I am trying out something. The reason for this particular structure is to create a "temporary" button for the user without telling them they are triggering the skip button (which they can also access through the front panel). The actual program has already a lot of buttons and essentially an extra OK button will only appear when a certain condition is met but the functionality would be the same as the skip button.
I have two While loops (let's call them Loop A and B). Loop B has another while loop within it (Loop B2). When a certain Boolean is true, a message box appears in Loop A and clicking the OK button should trigger the stop of Loop B2 while not stopping Loop B.
Even with Highlight switched on, I see that the condition for the stop of Loop B2 is True and yet it is still running.
The numeric values of Inner Loop and Outer Loop is just there to show if the loop(s) is still running or not.
Attached is a simplified sample vi.
Thank you in advance.
08-27-2020 06:31 AM
The program runs just like you have made it.
It also do what you have described.
Use the I in each While Loop as a debug to see when a Loop is running. Your random numbers are not the best.
Once you click on Skip or Ok in the dialog box, the lower Loop will continue to run over and over.
The inner Loop will run once per the outer loop cycle.
08-27-2020 06:39 AM
Yes, you're right. After tinkering with the timing (though your suggestion of using the i is much easier) I realized a while loop always executes at least once and because the outer loop is running, it executes once.
Changing the inner while loop into a case structure works.
But since the original program requires the inner while loop, I placed it within another case structure and now it works how I intended it to.
08-27-2020 08:24 AM - edited 08-27-2020 08:25 AM
@nikvl wrote:
But since the original program requires the inner while loop, I placed it within another case structure and now it works how I intended it to.
As an aside, why does the original program require an inner while loop? It sounds to me like the original program utilizes an architecture that is asking for more problems in the future. I suspect that the program could be rather readily converted to a state machine, which would be much more robust and could eliminate many of those local variables.
08-27-2020 09:29 AM
It is already a state machine, and some states have a while loop in them.
08-27-2020 11:50 AM
@nikvl wrote:
It is already a state machine, and some states have a while loop in them.
In my experience when I think that I need a while loop in a state it is because I have not properly defined all of the states. I prefer to use the existing while loop of the state machine. One of the complications of not using the existing while loop is stopping the program. I want to be able to push a button (or even better use the Panel Close? event) to exit the program without having to do something else to exit an internal loop. Having the internal loop also often leads to programming practices which promote race conditions.
I also noticed that you were using Value (signaling) property nodes in your example code. I'm assuming that this is because you have an event structure which triggers off of this in your real code.