04-24-2020 11:32 PM
How do I make my dialog box disappear after scanning data.
In other words when I scan, enter will be clicked grammatically, without clicking enter on the keyboard or without selecting 'ok' by mouse.
Thanks!
04-25-2020 06:49 AM - edited 04-25-2020 06:51 AM
@LV2020 wrote:
How do I make my dialog box disappear after scanning data.
In other words when I scan, enter will be clicked programmatically, without clicking enter on the keyboard or without selecting 'ok' by mouse.
Thanks!
You need to use a user event or a notifier to be able to stop the dialog VI from the caller VI:
04-25-2020 07:02 AM
Do you mean that you want the "Scan Your Code" control to be checked constantly until it's right?
You can create a while loop with an event structure inside. One of the events would be "Scan Your Code" Value Change. In that event, check that string however you like and then you can stop the loop and/or hit OK or whatever.
Note that you may want to right click on the control in the front panel and choose "Update Value while Typing"
04-25-2020 08:30 AM
You are using an Express VI, "Prompt User for Input". I wish that NI would provide a site called "How to Avoid Express VIs -- A Guide for Competent LabVIEW Developers" and would explain (a) how easy (and "better") DAQmx is than the Dreaded DAQ Assistant, and (among other things) (b) how easy it is to write a Modal Dialog Box that does precisely what you want (because you write the code) in creating a Dialog Box (with 0 buttons, 1 button, 2 buttons, 23 buttons, whatever you need).
LabVIEW allows you to create a VI that pops up and shows its Front Panel when called, disappears when done, and can accept inputs (to set defaults, for example) and provide outputs.
I recently went down the same path you did, using the Prompt User for Input, as I hadn't written anything that required a pop-up prompt. But a colleague asked for a pop-up on some code I'd written recently, so I, too, took the "short-cut", and quickly found myself frustrated by the limitations. Like @LucienM, I dived into how the Prompt User Express VI worked, and found the same messy code, but then remembered I'd written Modal Dialog VIs earlier, so I resurrected my old routines and created new ones.
Here's an example. This is a "Two-Button Dialog Box" that asks the User to enter the name of the "Tester" (the person running the test). The user pushes "OK" once this is done, or pushes "Cancel" to mean "Oops, I don't want to do this right now, tell the program to stop". Notice that the Front Panel includes a Decoration, a Flat Box (I've made the edge of the Box transparent) -- this allows me to manually size the Front Panel so as to hide the Controls and Indicators I don't want the User to see (or use an OpenG function, shown in Green on the Block Diagram Snippet, to do it for me).
The Block Diagram is simple. It largely consists of an Event Loop, here ended by pressing either OK or Cancel (which sets the OK Boolean Output to True or False). It would be easy to add code to (a) require that the User fill in Tester, (b) allow typing "Return" to end the Dialog without needed OK or Cancel, or (c) put a time limit on how long to wait.
The only other "extra steps" are to make this VI a Modal Dialog Box. That you do by setting some VI Properties. Start with Window Appearance. Choose "Dialog" (oh, really?). If you now click "Customize", you'll see that this does the following:
Now go to Window Run Time Position. I usually choose "Centered", but you can position it where you want (or leave this alone).
I'm also attaching the VI itself. It is written in LabVIEW 2019, but you should be able to recreated it from the "picture" of the Snippet, as the other two Cases should be obvious (both set the Stop Indicator to True, while OK returns True to OK, while Cancel returns False).
Bob Schor