10-30-2014 05:17 PM
I have an analysis script that parses through several data files - it runs for about one hour. From the script, I can display status and information in a non modal dialog. But I would like to include a Cancel (or Stop) button on the dialog which can be used to stop the running script. I can use variables to pass data to the dialog, but I can't get the dialog to respond to an event and pass a variable back to the running script. Am I missing something obvious?
10-31-2014 02:41 PM
Hi Paul,
Do you have an object reference to that non-modal dialog? If so, what happens when you execute Dialog.Cancel?
Brad Turpin
DIAdem Product Support Engineer
National Instruments
11-02-2014 09:22 PM
Hi Brad,
The issue is that while the script is running, I can't get the dialog to respond to my Stop button press. When I click the button, I don't get a response. I am using DIAdem 2012. Would a newer version handle this differently? I attached my simple .sud file where I am polling in my script for B10 to be set. Am I doing this incorrectly?
Thanks again,
Paul
11-03-2014 06:09 PM
Hi Paul,
In your attached SUD file, if you add the Dialog.Cancel method to the bOK_EventClick sub, does that give you the functionality you are looking for? It should close the dialog box. The other lines appear to be formatted correctly from what I can tell.
11-04-2014 09:51 PM
Hi Steven,
Thanks for your suggestion. This didn't work either. For some reason, while the script runs, the events of the non modal dialog don't fire (get triggered). It seems that the dialog handler doesn't run in a separate thread to catch (and handle) these events.
I attached a simple test script and nonModelDialog.sud files. I looked for an equivalent script example that would stop a script with a dialog button press, but didn't find one.
Thanks again, Paul
11-05-2014 02:49 PM
Hi Paul,
Try using the SUDDlgCreateEx() command and setting the SUDDlgkeepEnabled parameter to true. This should allow the user to make selections in the dialog box even while the script is running.
You will need to add some error handling or checking to avoid getting errors if DlgHandle is thrown out while the loop is still running.
11-05-2014 03:00 PM
That is the fix! Thanks for showing that to me.