LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Run only once in case structure

Hello,
 
I have a menu set up that is wired to a case structure.  Of course the menu is some boolean buttons that are set to switch when pressed so the case will stay open as long as the button is true.
 
inside that case I have another menu and a case structure that operates the same.  In one of these cases I have a piece of code that I only want to run once.  I have tried the while loop that runs once and a for loop that only runs once, but the section of code seems to run continuosly instead of just once.  It works ok if I use any of the latch functions but not the switch when pressed functions.  However, I need the button to stay pressed until the user is finished with that case.
 
I really don't want to use an event structure as I was saving that for another piece of code that monitors inputs.
 
Anyone have a suggestion?
0 Kudos
Message 1 of 5
(6,172 Views)
If you want to reset the boolean when the case is done you can use a local variable.  Wire a constant from in the case structure to out of it into the local.  Depending on your code you may be able to also use a flat sequence structure also.  Either way a local is an easy way to do that.
0 Kudos
Message 2 of 5
(6,170 Views)

Evan thanks for the reply but,

I did not include enough information in my original post.  Its not resetting the boolean that is the problem.  There is more than one piece of code in the case, and I need one section to execute only once. 

Basically I have a LV2 style global vi that sends a message to a message manager with info about what is happening.  Basically it says "user XX reqested control of shutter xxx at xxxpm" .  I need the case to stay true until the user is done with a particular shutter, but I need the message subvi to only run once.  So I need the case selector button to stay true until the user de-selects it, and the message send subvi to execute only once while that particular case is true.

Thanks,

Nathan

0 Kudos
Message 3 of 5
(6,164 Views)
Typically, this works easiest with a shift register and and a boolean "implies" function.
 
In the code example (see image), the button is set to "switch until released". (Of course you probably don't need the NOT, simply place your one-time code into the FALSE case ;))
 
 
 
 

Message Edited by altenbach on 01-26-2007 01:52 PM

Message 4 of 5
(6,149 Views)
Thanks,
 
I'm not familiar with the implies function but I'll give it a try.
 
-Nathan
0 Kudos
Message 5 of 5
(6,110 Views)