DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

How to halt a script from a non modal dialog?

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?

0 Kudos
Message 1 of 7
(5,653 Views)

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

0 Kudos
Message 2 of 7
(5,626 Views)

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

0 Kudos
Message 3 of 7
(5,596 Views)

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. 

Steven Gloor
Staff Customer Engineer - CTA, CLD
0 Kudos
Message 4 of 7
(5,565 Views)

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

Download All
0 Kudos
Message 5 of 7
(5,532 Views)

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.

Steven Gloor
Staff Customer Engineer - CTA, CLD
Message 6 of 7
(5,517 Views)

That is the fix! Smiley Happy Thanks for showing that to me.

0 Kudos
Message 7 of 7
(5,515 Views)