TobbeSweden
14th June 2008 23:53 UTC
Checking if a section is selected
Compiling this code:
!include "MUI2.nsh"
!include LogicLib.nsh
Name "SectionTest"
OutFile "SectionTest.exe"
ShowInstDetails show
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
Section "One" SecOne
DetailPrint "Section one"
${If} ${SectionIsSelected} ${SecTwo}
DetailPrint "Section two is selected"
${EndIf}
SectionEnd
Section "Two" SecTwo
DetailPrint "Section two"
SectionEnd
gives me this warning message: unknown variable/constant "{SecTwo}" detected, ignoring (macro:_SectionFlagIsSet:2)
Why do I get that warning? (I guess it is because SecTwo comes after SecOne but I don't understand why that is a problem). Is there anyway I can make it work? I do not want to switch the order of the sections.
demiller9
15th June 2008 00:08 UTC
Yes, it is because section two is after the code that tried to reference it. You can create and call a function to perform what you want done when the section is selected. Just put the function after section two.
Makensis is a 'one pass' compiler. It does not know the definition or location of variables, defines, functions until it has processed them. You can't reference any of those things before they get defined.
Don
TobbeSweden
15th June 2008 01:42 UTC
I solved it like this:
!include "MUI2.nsh"
!include LogicLib.nsh
Name "SectionTest"
OutFile "SectionTest.exe"
ShowInstDetails show
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
Section "One" SecOne
SectionEnd
Section "Two" SecTwo
SectionEnd
Section "-OneTwo"
${If} ${SectionIsSelected} ${SecOne}
DetailPrint "Section one"
${If} ${SectionIsSelected} ${SecTwo}
DetailPrint "Section two is selected"
${EndIf}
${EndIf}
${If} ${SectionIsSelected} ${SecTwo}
DetailPrint "Section two"
${EndIf}
SectionEnd