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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

execute case structure only once

The boolean switches outside of the loop means they'll only be read once.  If False the case structure will never execute.  If True, the case structure will always execute.

 

When you say "execute only once", can you be more specific?

Only once like they all execute on the first iteration of the While Loop?

Only once as in they don't, but you when you press a button they will, but if you press it again they won't?

 

Explain what you want to do more clearly.

It is straight up boolean logic,  True or False.  So if you write down on a PC of paper what your True condition would be and your False condition, you can figure out the boolean logic to make that happen.

Message 11 of 13
(426 Views)

@Jub-Jub wrote:

 

Specifically, how can each of the case structures in the attached pic be programmed to execute once?  Others have suggested local variables, "implies statements", First Call?, Shift Registers, but am not sure how to implement them

 


Your case structures execute with every iteration of the loop and run whatever case is selected by the selection terminal. TO have the execute only once, delete the outer while loop.

 

If you want e.g. the TRUE case only execute on the first iteration of the while loop, connect an "=0" to the iteration terminal and it's output to the case structure. In that case, explain the purpose of the switches.

 

If you want the case structure to go true once whenever a switch is operated, their terminal needs to be inside the while loop and their mechanical action needs to be set to latch (right-click...mechanical action...latch when released, for example).

 

(You appended to an old thread instead of starting your own, preventing you to mark a solution. You should have started a new thread for a new problem. Also, we cannot really debug images, so attach your VI, explain exactly how you run it, what buttons you press, what you expect to happen and what happens instead. Looking at non-functioning code does not tell us what you really want.)

 


@Jub-Jub wrote:

 

Specifically, how can each of the case structures in the attached pic be programmed to execute once?  Others have suggested local variables, "implies statements", First Call?, Shift Registers, but am not sure how to implement them

 


When quoting "others", I recommend to include a link to their post.

Message 12 of 13
(419 Views)

Well, you play the sounds inside the loop. This loop has a loop iteration counter 'i', i'll come back to this.

Since you're not reading the buttons inside the loop, and value active when entering will stay until it exits, so currently if a button a pressed, the sound will continue until you stop the loop with button 4. I assume you follow so far.

To only play it once, you'll need "If incoming signal is True AND 'i' is 0"

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 13 of 13
(414 Views)