I can't seem to grab the value from a variable which is changed by user operation in a dialog box. I have attached the relevant section of the script below.
Basically, I use an INITIALIZE subroutine to create the pre-filled-in dialog box for a charting program. The user can accept the predefined terms or change them. The script then captures whatever values are in the variables (either predefined or changed values) and generates the chart.
I then want to bring up the dialog box again for another chart with the latest values in place. The ComboBox section works fine (remembers any changes) but the variable var_SMA1 which is created with an Edit function and the CheckBox variable chkboxSMA always reverts back to the initial values even if user changed. Through my testing I am guessing that the Dialog is initialized once (and Checkbox and Edit variables are established) and not revisited. ComboBox variables are revisited so new data is used. If this is the case - how do I re-initialize the dialog box?
Or, if I am completely wrong - how do I get new values for CheckBox and Edit variables to be used on subsequent Dialog Box uses?
GoSub>INITIALIZE
Dialog>PARAMETER
Caption=STARTUP OPTIONS
Top=20
Width=1000
Left=20
Height=700
ComboBox=Size,35,37,75,Default%CRLF%Small%CRLF%Medium
Let>PARAMETER.Size.ItemIndex=%var_Size%
CheckBox=chkboxSMA,SMA,20,97,50,%var_chkboxSMA%
Edit=SMA1,80,97,30,%var_SMA1%
Button=OKAY,320,610,75,25,1
Button=CANCEL,645,610,75,25,2
EndDialog>PARAMETER
SHOW>PARAMETER,RESULT
Gosub>CAPTURE
Remark>SOME PROCESSING
Goto>SHOWDIALOG
Label>ENDPOINT
Remark> ========= SUBROUTINES
SRT>INITIALIZE
Let>var_Size=0
Let>var_chkboxSMA=FALSE
Let>var_SMA1=30
END>INITIALIZE
SRT>CAPTURE
Let>var_Size=PARAMETER.Size.ItemIndex
Let>var_chkboxSMA=%PARAMETER.chkboxSMA%
Let>var_SMA1=%PARAMETER.SMA1%
END>CAPTURE
Problem accessing variables from Dialog box
Moderators: JRL, Dorian (MJT support)
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
I think you are stuck at this point. I have run into the same thing.
Here is a list of a number of messages and requests that I have made in the past re Dialog Boxes. There does not seem to be a lot of messages on this topic, I wonder if many people are using them? Perhaps added comments from you will help to see some requests implemented of these in the next release? (Some of these have already been addressed, but are here for history).
http://www.mjtnet.com/usergroup/viewtop ... ght=dialog
http://www.mjtnet.com/usergroup/viewtop ... ent+dialog
http://www.mjtnet.com/usergroup/viewtop ... ght=dialog
http://www.mjtnet.com/usergroup/viewtop ... ght=dialog
http://www.mjtnet.com/usergroup/viewtop ... ght=dialog
http://www.mjtnet.com/usergroup/viewtop ... ght=dialog
http://www.mjtnet.com/usergroup/viewtop ... ght=dialog
http://www.mjtnet.com/usergroup/viewtop ... ght=dialog
http://www.mjtnet.com/usergroup/viewtop ... est+dialog
http://www.mjtnet.com/usergroup/viewtop ... ght=dialog
http://www.mjtnet.com/usergroup/viewtop ... est+dialog
http://www.mjtnet.com/usergroup/viewtop ... est+dialog
http://www.mjtnet.com/usergroup/viewtop ... ent+dialog
http://www.mjtnet.com/usergroup/viewtop ... ght=dialog
The first one listed specifically deals with SRT and Dialogs. I have tried to list the others chronologically, oldest first.


http://www.mjtnet.com/usergroup/viewtop ... ght=dialog
http://www.mjtnet.com/usergroup/viewtop ... ent+dialog
http://www.mjtnet.com/usergroup/viewtop ... ght=dialog
http://www.mjtnet.com/usergroup/viewtop ... ght=dialog
http://www.mjtnet.com/usergroup/viewtop ... ght=dialog
http://www.mjtnet.com/usergroup/viewtop ... ght=dialog
http://www.mjtnet.com/usergroup/viewtop ... ght=dialog
http://www.mjtnet.com/usergroup/viewtop ... ght=dialog
http://www.mjtnet.com/usergroup/viewtop ... est+dialog
http://www.mjtnet.com/usergroup/viewtop ... ght=dialog
http://www.mjtnet.com/usergroup/viewtop ... est+dialog
http://www.mjtnet.com/usergroup/viewtop ... est+dialog
http://www.mjtnet.com/usergroup/viewtop ... ent+dialog
http://www.mjtnet.com/usergroup/viewtop ... ght=dialog
The first one listed specifically deals with SRT and Dialogs. I have tried to list the others chronologically, oldest first.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!
An example of setting values with variables and then setting them to what the user entered to ensure the dialog always shows what the user entered:
Dialog>Dialog1
Caption=Dialog1
Top=321
Width=183
Left=110
Height=137
CheckBox=msCheckBox1,Check This,24,24,97,%CheckVar%
Edit=msEdit1,24,48,121,%EditVar%
EndDialog>Dialog1
//Default values
Let>CheckVar=True
Let>EditVar=Hello
Label>start
Show>Dialog1,result
Let>CheckVar=Dialog1.msCheckBox1
Let>EditVar=Dialog1.msEdit1
Goto>start
Dialog>Dialog1
Caption=Dialog1
Top=321
Width=183
Left=110
Height=137
CheckBox=msCheckBox1,Check This,24,24,97,%CheckVar%
Edit=msEdit1,24,48,121,%EditVar%
EndDialog>Dialog1
//Default values
Let>CheckVar=True
Let>EditVar=Hello
Label>start
Show>Dialog1,result
Let>CheckVar=Dialog1.msCheckBox1
Let>EditVar=Dialog1.msEdit1
Goto>start
MJT Net Support
[email protected]
[email protected]
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
Works good, I must have missed something somewhere. Thanks for the working sample. I had forgotten that my problem was using variables for Captions could not be revisited. Anyway, a refresher course is always helpful. Thanks again.....
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!
Problem solved
Using the template provided by support above (Thanks!) I managed to fix my problems. There were a couple of big gotchas which plagued me - I had one instance of a LET =i+1 (in other words, I left off a ">" sign). This defined a variable with a name of {blank} and every time I tried to initialize some other variable with a statement like Let>SMAvar= it tried to use the value i+1. Caused some very strange results.
The other big gotcha was that I ran the Initialization routine defining all my initial values for the dialog at the top of the script. I then used the Dialog Box code. The dialog initialized fine but would not retain any user changes. Moving the Dialog Box definition to the very top, then the Initialization routine, then the SHOW> command fixed the problem (perhaps a note in the help file might save other users the grief?).
Anyway, the Dialog Box is a powerful addition to Msched and I will use Dialogs more now that I have gotten over the learning blues.
Thanks to MJTnet support and Bob for help here.
Dave
The other big gotcha was that I ran the Initialization routine defining all my initial values for the dialog at the top of the script. I then used the Dialog Box code. The dialog initialized fine but would not retain any user changes. Moving the Dialog Box definition to the very top, then the Initialization routine, then the SHOW> command fixed the problem (perhaps a note in the help file might save other users the grief?).
Anyway, the Dialog Box is a powerful addition to Msched and I will use Dialogs more now that I have gotten over the learning blues.
Thanks to MJTnet support and Bob for help here.
Dave