11-21-2013 01:02 PM
I swear I've asked this before, but I cannot find my post from a previous user name... So, sorry if I am asking it again.
I'm having a little difficulty using global variables between a parent script and a child SUD. Here is what is happening:
For some reason, the parent script does not recieve the new value of the global var, even though the global var is the file name as confirmed using msgbox within the SUD.
A couple things I figured out:
I want to understand this behavior and to make sure I'm doing things correctly, since I have MANY different global variables, and don't want to type them all into the Event Terminate sub.
Thanks.
11-21-2013 01:09 PM
This feels wrong, but is my current workaround for this (R210_File is the global var), comment out the "R210_File=EditBox1.Text" and the parent script doesn't recieve the updated value. :
Sub EditBox1_EventRefresh(ByRef This) 'Created Event Handler EditBox1.Text=R210_File End Sub Sub Dialog_EventTerminate(ByRef This) 'Created Event Handler R210_File=EditBox1.Text End Sub
11-22-2013 01:06 AM
Hi RussellSenior,
The best way to exchange information between a main script and SUD dialogs is the last parameter of the command "SUDDlgShow". This parameter is either a single variable or a VBS class which covers several variables. In the SUD you read this parameter in the dialog initialize event and write back the content of the dialog in the terminate event.
Please find attached an example for this kind of information exchange. (It is one of my standard examples extended with your request)
Greetings
Walter
11-22-2013 08:35 AM
I was afraid of that. I'm not very confident making and using my own classes with Diadem. Guess it's time to learn!
Thanks.
11-27-2013 03:44 AM
That is very nice example for transfer variables, which you don't need to save. E.g. it doesn't matter if these params is deleted after Diadem restart (or after calling ScriptCmdReset).
I'm usually working with user settings, which users expect to be same until user changes it.
For that I'm used to work with windows registry, where can I use tree structure of my params, look on current content and I know, that settings is always there.
Greetings
Radek
11-27-2013 08:41 AM
That's an interesting approach, I never considered utilizing the registry. For user settings with Diadem, I usually create a text file to keep and store all the parameters. I have to create my own functions to edit/read/write specific ini data. It would be nice if Diadem had a set of built in functions for ini files.
11-28-2013 01:22 AM
I've modified Walter’s script to use registry storage.
12-02-2013 01:04 PM
Hi Russell,
I think the gotcha you ran into was that the SUDialog can be configured to restore the original states of specific global variables it knows about if the <Cancel> button is pressed. First choose the menu "Edit >> Variables..." in the SUDialog Editor. Now select the variable you wish to change and click the <Edit> button. Finally uncheck the "Reset after cancel" checkbox and click the <OK> button twice and re-save the *.SUD file.
See if that helps,
Brad Turpin
DIAdem product Support Engineer
National Instruments