LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

execute when user presses ENTER

Solved!
Go to solution

Hello,

I have a program that scans a serial number and gives an output.

Rightnow, I scan the serial number and hit run on the laview toolbar.

But, I want to program it so that when the user scans a number it would automatically output results, without me hitting run or an OK button continuously.

 

I have attached my vi below.

 

So, does anyone have any tip for me on how I could go about that?

 

Thanks a lot in advance,

Yeshani

0 Kudos
Message 1 of 8
(3,021 Views)

Just some feedback.  Your VI needs a timeout inside the while loop or it will use up most of your cpu.

 

I can't see from the code where the scanning is done, so I assume that you are inputting the values of the serial number.  In this case, you would just add an event structure and create a case for the serial number and exit button as shown below.  You still have to hit the run button to execute the code, which is true for any VIs in editor mode.  The code will not terminate unless the exit button is pressed.  Everytime the serial number changes, the code will automatically output the results.

 

warranty check.png

 

If you were using a barcode scanner, you would have to create a case to read from the the barcode scanner then process the information.

 

Message 2 of 8
(3,009 Views)
Solution
Accepted by topic author ywij

Hi,

 

Here is a version that uses polling.  The input has it's properties so that it doesn't update untill you hit enter.

The reference is actually a local variable. 

Polling and local variables are not often smiled upon, but for "just a text entry" app, it should work well. 

 

 

warranty poll.png

-------
Mark Ramsdale
-------
Message 3 of 8
(2,992 Views)

Mark The event structure now ships with all versions of LabVIEW.  polling is now passe! Smiley Very Happy


"Should be" isn't "Is" -Jay
Message 4 of 8
(2,982 Views)

Hi Jeff,

 

I agree, and I always put some notification to that effect in my posts.  I generally assume that folks with issues that post VI's without event structures just want a simple solution for a short term problem.  Hopefully they are continuing to use LabVIEW and will move up to event structures. 

-------
Mark Ramsdale
-------
0 Kudos
Message 5 of 8
(2,952 Views)

Hello Mark,

 

Thank you very much! I am still learning labVIEW and quite new to this. I tried to understand your modifications but still have trouble. Would you please explain the use of shift regieter here and what kind of node you have there for String.

I really appreciate it.

 

0 Kudos
Message 6 of 8
(2,905 Views)

Hi nikk07,

 

There is a good example about the concept behind a shift register here. Essentially they give you the ability to retain data through different iterations of a loop.

 

There is also some information about string constants here. I believe this is what you were referring to in the second part of your question.

Message 7 of 8
(2,851 Views)

Thank you!!

0 Kudos
Message 8 of 8
(2,829 Views)