Use global variable in dialog's ControlCustomScript

It seems you're using an AdBlocker or JavaScript is disabled!

This sites offers only FREE software and it's supported by a few advertisement boxes (no intrusive popups).

This 10 seconds wait is to let you update your AdBlocker whitelist...

Got it, show me the content...
Please enable JavaScript!
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: 1647
Joined: 25 Mar 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).