Use global variable in dialog's ControlCustomScript

Anonymous user
Use global variable in dialog's ControlCustomScript

Hi! I have used Dialog Designer to create a dialog with radio buttons and worked out fine. I have successfully managed to handle radiobuttons selections. However, I have the following problem: when I switch between pages my radiobutton selection disappears. So I want to somehow store the selected value in the outside script (I used a global variable like this Var /GLOBAL MAIN_SELECTION and store the value selected in each of the onClick callbacks for each radiobutton) and then use this value when dialog is recreated (defined in CreateFunctionCustomScript). 

The script I added was the following

${If} $MAIN_SELECTION == "1"
    MessageBox MB_OK|MB_ICONEXCLAMATION "Select radio 1" /SD IDOK
    ${NSD_Check} $hCtl_MainPage_RadioButton1
${If} $MAIN_SELECTION == "2"
    MessageBox MB_OK|MB_ICONEXCLAMATION "Select radio 2" /SD IDOK     
    ${NSD_Check} $hCtl_MainPage_RadioButton2
${If} $MAIN_SELECTION == "3"
    MessageBox MB_OK|MB_ICONEXCLAMATION "Select radio 3" /SD IDOK
    ${NSD_Check} $hCtl_MainPage_RadioButton3
${If} $MAIN_SELECTION == "4"
    MessageBox MB_OK|MB_ICONEXCLAMATION "Select radio 4" /SD IDOK
    ${NSD_Check} $hCtl_MainPage_RadioButton4

But it doesn't work. My question is.
1) How can I restore the selected radiobutton when going back and forth between pages (back in my case)?
2) Is it possible and how to communicate some variables between main script and scripts generated by Dialog Designer?
Looking forward to any tip!
Thanks in advance.

Posts: 1220
Joined: March 25, 2012 - 01:19
Re: Use global variable in dialog's ControlCustomScript

If you defined ${MAIN_SELECTION} variable outside th .nsdinc file and before including it it should work.
What's the output of the first MessageBox? I mean, what's the value of ${MAIN_SELECTION} variable?


How do you store the value into the variable?
I'd like to give a look to the whole script, if you like too.
Please remove everything but the radiobuttons page and a page before/after, zip all the .nsi* files together and post it here (or send it to me through the contact form).


Warning, JavaScript is disabled!

JavaScript is not available, maybe because you disabled it globally into your browser settings or you are using an addon like NoScript.

We do not have any dangerous JavaScript running here.
Please enable JavaScript; if you're using NoScript this image will help you adding CoolSoft to your whitelist.

Thanks for your comprehension and enjoy CoolSoft.