LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how can i exit a while loop using a string control?

i have a pop-up dialogue box w/ a string control for the user to enter data. It is in a while loop, and I want to exit the loop upon a CR, TAB, or SPACE BAR. i'll need to get rid of the extra char as well. thanks in advance.
0 Kudos
Message 1 of 11
(5,008 Views)
This is quite simple. All you do is monitor each character that is entered, and when a /r (carriage return) or /n (end of line) is entered, you just recognize that with logic, and terminate the loop.

If you still have trouble, I have some sample code, but the sample code is from a single character processor, so it may be more difficult than you need.

Try this: In your while loop, insert a "match pattern" with the pattern to match being /r. If the users presses the "Enter" key (the one on the main keypad, not the one on the numberpad) this will produce an integer greater than one for the offset output. When the output of the offset is >= 0, you will get a true. Wire this boolean from the comparison to your loop termination, and set it to stop if tru
e.
0 Kudos
Message 2 of 11
(5,009 Views)
Hi,
 
     I am trying to send a text through the serial port by typing in data and hitting "ENTER" on my keyboard. How do I do that? I created a while loop to search for a carriage return but nothing is happening. What other techniques can I use?
0 Kudos
Message 3 of 11
(4,859 Views)
Hi newguy,
could you post the code, which is supposed to detect the Enter?
Some suggestions: I assume you set the string control to "update value while typing" and then scan for Enter. In this case Enter is represented as Line feed, like the constant you can find in the String Palette. If you search for this (it's a decimal 10) character, you should be able to react to Enter.
Greets, Dave
Greets, Dave
0 Kudos
Message 4 of 11
(4,847 Views)
You may also want to try an event structure, with a "Keydown" event registered for your string control.

The Event Data Node will return what key was pressed, and you can react accordingly from there.
0 Kudos
Message 5 of 11
(4,820 Views)
I would like to try the event structure but I don't think I have that function. I could be looking in the wrong place. I have labview 7.1-base
0 Kudos
Message 6 of 11
(4,814 Views)
Could you show an example of this? I was modifying the BasicReadandWrite.vi that was provided.
0 Kudos
Message 7 of 11
(4,812 Views)
I have 8.2 so I can't attach a vi that would help you, but there's an image attached which might.  Basically all I did was wrap the "Basic Write and Read" vi's block diagram in the appropriate structures.  Before using event structures though, you should read about them in the help.  They can be incredibly useful, but if you're not certain of a part of their functionality, they can be really frustrating.

I took to mean from your latest post that you were able to find them.  As far as I know, event structures exist in all versions of LabVIEW 7 and up (someone please confirm this)

Message Edited by Will.D on 12-05-2006 01:11 PM

0 Kudos
Message 8 of 11
(4,789 Views)

Hi,

    The labview version I have (7.1-base edition) does not contain the event structure. I believe they are found in the other edition.

0 Kudos
Message 9 of 11
(4,767 Views)
Here's an example that doesn't use the event stucture. I just set the key navigation of the 'Enter' button to <ENTER>. You could hide the Boolean if you want.
0 Kudos
Message 10 of 11
(4,762 Views)