Skip to content
⌘ NSIS Forum Archive

Section still installs after deselection

3 posts

ascTim#

Section still installs after deselection

Hi, I need some help... again. Sorry, but I can't find my mistake.

I created a custom page with 5 sections that are autochecked when starting the installer.
For some reason, it will always execute all 5 sections even when they are unchecked.

Any idea why that happens?

Var Chk_Box1
Var Chk_Box2
Var Chk_Box3
Var Chk_Box4
Var Chk_Box5
Page custom MyPage1 MyPage1Leave
Function MyPage1
nsDialogs::Create 1018
!insertmacro MUI_HEADER_TEXT "Components" "Komponenteninstallation"
Pop $0
${NSD_CreateLabel} 0 0 100% 15u "Select components:"
${NSD_CreateLabel} 0 150 100% 15u "Custom Text"
Pop $0
${NSD_CreateCheckbox} 30 25 350 10u "Section1"
Pop $Chk_Box1
${NSD_CreateCheckbox} 30 50 350 10u "Section2"
Pop $Chk_Box2
${NSD_CreateCheckbox} 30 75 350 10u "Section3"
Pop $Chk_Box3
${NSD_CreateCheckbox} 30 100 350 10u "Section4"
Pop $Chk_Box4
${NSD_CreateCheckbox} 30 125 350 10u "Section5"
Pop $Chk_Box5
;Auto check checkboxes
${NSD_Check} $Chk_Box1
${NSD_Check} $Chk_Box2
${NSD_Check} $Chk_Box3
${NSD_Check} $Chk_Box4
${NSD_Check} $Chk_Box5
nsDialogs::Show
FunctionEnd
Function MyPage1Leave
${NSD_GetState} $Chk_Box1 $0
${If} $0 <> 0
    !insertmacro SelectSection ${SID_1}
${Else}
    !insertmacro UnselectSection ${SID_1}
${EndIf}
${NSD_GetState} $Chk_Box2 $0
${If} $0 <> 0
    !insertmacro SelectSection ${SID_2}
${Else}
    !insertmacro UnselectSection ${SID_2}
${EndIf}
${NSD_GetState} $Chk_Box3 $0
${If} $0 <> 0
    !insertmacro SelectSection ${SID_3}
${Else}
    !insertmacro UnselectSection ${SID_3}
${EndIf}
${NSD_GetState} $Chk_Box4 $0
${If} $0 <> 0
    !insertmacro SelectSection ${SID_4}
${Else}
    !insertmacro UnselectSection ${SID_4}
${EndIf}
${NSD_GetState} $Chk_Box5 $0
${If} $0 <> 0
    !insertmacro SelectSection ${SID_5}
${Else}
    !insertmacro UnselectSection ${SID_5}
${EndIf}
FunctionEnd
Section Sec1 SID_1
;Some Install stuff
SectionEnd
Section Sec2 SID_2
;Some Install stuff
SectionEnd
Section Sec3 SID_3
;Some Install stuff
sECTIONeND
Section Sec4 SID_4
;Some Install stuff
SectionEnd
Section Sec5 SID_5
;Some Install stuff
SectionEnd 
I'm also recieving some warnings. Maybe they help you (more than they help me at least):

warning: !warning: MUI_LANGUAGE should be inserted after the MUI_[UN]PAGE_* macros (macro:MUI_LANGUAGE:8)
warning: unknown variable/constant "{SID_1}" detected, ignoring (macro:SelectSection:4)
warning: unknown variable/constant "{SID_1}" detected, ignoring (macro:UnselectSection:4)
warning: unknown variable/constant "{SID_2}" detected, ignoring (macro:SelectSection:4)
warning: unknown variable/constant "{SID_2}" detected, ignoring (macro:UnselectSection:4)
warning: unknown variable/constant "{SID_3}" detected, ignoring (macro:SelectSection:4)
warning: unknown variable/constant "{SID_3}" detected, ignoring (macro:UnselectSection:4)
warning: unknown variable/constant "{SID_4}" detected, ignoring (macro:SelectSection:4)
warning: unknown variable/constant "{SID_4}" detected, ignoring (macro:UnselectSection:4)
warning: unknown variable/constant "{SID_5}" detected, ignoring (macro:SelectSection:4)
warning: unknown variable/constant "{SID_5}" detected, ignoring (macro:UnselectSection:4) 
Anders#
The first warning should be obvious.

The SID_ warnings means the section id has not been defined yet and you need to move the sections above the functions in your script.