03-06-2010 12:50 PM
I am exploring (= teaching myself) how key codes are captured by the Event structure. I built a simple test routine (see below) that has a 1 second timeout that increments each tick (allowing the program to exit after 30 seconds) and a Key Down? filter that shows me what happens when I type various keys.
When I first ran it, I didn't have the Discard? terminal wired, and noticed that ^Q popped up a "Quit?" dialog, while ^P popped up a "Print Screen" dialog. I'd wanted to "capture" these keystrokes for "Quit" and "Pause". I then wired "True" to the terminal, and no additional dialog box popped up (as expected).
However, I noticed that typing ^P had the effect of restarting my While loop (there's an indicator, not visible here, inside the Timer event that shows the current count, 1, 2, 3, ..., and when I type ^P, it resets to 1 and starts counting again). I'm guessing that the entire program is restarted, but was not aware of this behavior!
Two questions. First, is this documented, and if so, where can I read about the "intended" actions of this keystroke? Second, is there a way to "turn off" this behavior and have ^P be treated as just a combination of keys, whose effect is "discarded" by the Event loop?
Bob Schor
Solved! Go to Solution.
03-06-2010 12:59 PM
03-06-2010 01:11 PM
Duh -- of course! Here I was looking for something complicated, and it was a silly error ... Thanks for keeping me humble!
BS
03-08-2010 01:31 PM
Mistakes like this can be avoided by unchecking the "Use default if unwired" checkbox when right clicking on the blue terminal on the right side of the event structure. Unchecking will remove the small white box within the blue one. I think the default is to have this box checked. Unchecking will force you to wire to the terminal in each case of a case structure or event structure, or you VI will be broken.
Of course there are times when using default if unwired is perfectly OK. So far, the only time I have ever used "use default if unwired" was when I put in a boolean in a case or event structure to stop a while loop, where the boolean was only in the "exit" case. If not in the exit case, I use the default, which is False, so the loop continues.