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: 

Password SubVI with Enter/Return key control

Solved!
Go to solution

Hi all, I am a self-taught LabVIEW user. I hope somebody here can help me solve this problem which is driving me nuts.

 

I'm trying to make a small password prompt. Only by entering the correct password a certain function is executed at runtime. My code was working smoothly until I realized that pressing the "Return" key in the password prompt added a new line; as a result the user is forced to use the OK button. I wanted to catch the Return key to make it work like a "standard" password prompt.

 

This is what is driving me nuts: my code works perfectly if I single-step it. If I run the code (CTRL+R) when I press "Return" the password is not accepted. A probe tells me that the password is always blank in that case. If I use the OK button everything works.

 

I implemented my password subVI with a small state machine, so that both the OK button and the Return key are directing to the same state. In the same way I also catch the Escape key, to work as the Cancel button, and that works smoothly. I also use the Discard function to drop the Return key so that my string does not get an extra unwanted new-line. I cannot possibly think of any race condition that can make my code working only when going through it slowly, step-by-step.

 

I am completely at a loss, and I hope somebody can help me! Thanks!

 

PS: I only attached the VI because due to the state-machine nature I would have had to post a bunch of screenshots. I can do that tomorrow if you need me to.

0 Kudos
Message 1 of 5
(3,333 Views)
Solution
Accepted by topic author vpicco
Right click on the text field where you are entering the password and select "update while typing"

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 5
(3,327 Views)

It works! Thank you!

 

That is one of those "LabVIEW things" that I will never understand...

0 Kudos
Message 3 of 5
(3,276 Views)

Better yet.

 

Select "Limit to Single Line" instead

Use the Value Change event for Password (The value will change when Enter is pressed)

Add a Password Mouse Leave event to remove focus

Add a Key Up event to catch "Esc" (ScanCode = 0x01)

Basically- try this mod:

 

Password.png


"Should be" isn't "Is" -Jay
0 Kudos
Message 4 of 5
(3,264 Views)

Lots of good suggestions too. Thanks!

0 Kudos
Message 5 of 5
(3,261 Views)