Archive: disabling component checkbox based on variable


disabling component checkbox based on variable
I want to disable a component checkbox based on value contained in one of the variables. Here is the code I tried to use.

Section /o "Server"
${If} $UserRegValue != '1111 2222 3333 4444'
SectionIn RO
${EndIf}
SectionEnd


The problem is that the checkbox is disabled even if $UserRegValue contains string '1111 2222 3333 4444'. How do I achieve conditional disabling of checkbox ?

regards,
Jatin.


SectionIn is compile time only. To disable it on runtime, add the SF_RO flag using the macros in Sections.nsh.

Section /o Server Server_SEC
SectionEnd
Function .onInit
${If} $UserRegValue != '....'
!insertmacro SetSectionFlag ${Server_SEC} ${SF_RO}
${EndIf}
FunctionEnd

thanks a lot


Hi Kichik,

I tried your idea, but it didn't work since function .OnInit is run at the begining of the script when value $UserRegValue is not set yet. Or I did some wrong?
Can you give me more details?

Thanks,

Jue


$UserRegValue is a specific variable for jatinkulkarni's script. You should replace that with whatever test you have in your script.


Actually I use variable R9 instead, but it is not set at the begining.
Thanks.


More ideas?


If you don't set it, it won't be set.


But it is set afterwards.
I would like to set the variable afterwards and then base on the value of the variable to disable a section in component page

Thanks for your answer.


Hi,
My problem is, the value of the variable will be set according to the selection by user, but function .onInit runs before this, so the value of the variable is not set at that time.

Thanks for your reply.


Then don't set the component selection in .onInit. Set it as soon as you can set $R9. As long as it's before the components page is displayed, it should be good enough.


The value I can set when I leave the custom page.
All the sections will show up in component page. Am I wrong? So where can I check the value of the variable and then set the section to be disabled?

Thanks in advance.