Archive: how to check which components are being installed?


how to check which components are being installed?
I'm writing an installer with two installation components and a component selection page and this works fine. However, I need to show a certain custom page only if a certain one of the components is being installed, so how do I check that a certain component has been selected for install? Is there a variable I check the value of, or maybe a certain macro?

thanks
alex


You can declare user variable (for example Var Sec).
Inside controlled section sets value for this variable (for example StrCpy $Sec "installed"). And before initialize custom page compare variable with this value (for example StrCmp $Sec "installed" go_if_inst go_if_not_inst).


It'd be easier to use ${SectionIsSelected} with LogicLib

!define LOGICLIB_SECTIONCMP
!include LogicLib.nsh

Page Custom myCustom

Function myCustom
${If} ${SectionIsSelected} ${SecID}
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "ioFile.ini"
${EndIf}
FunctionEnd


-Stu

By the way how to check or uncheck from the NSIS code? In fact, at the beginning I detect if a soft is installed, so, in the select components page, I'd like to have it unchecked.


Affrow, your example easier and more proper.


Use the SelectSection and UnselectSection macro's in Sections.nsh...

For example:
!include Sections.nsh

!insertmacro SelectSection ${SecID}

-Stu


Did you want to uncheck section?


thanks for the replies!
Yup, I went off and trawled through some of the .nsh files and found interesting things. Sections.nsh is worth a look...
all working now anyway, thanks!
alex


I try using Afrow UK's code to determine what components are selected, but it only appears to respond to the first checkbox on the component page, no matter what I enter as section ID.

I am using the LogicLib If-statement in the Leave function of the Components page.

Example:


Section "first" SEC_01
SectionEnd

Section "second" SEC_02
SectionEnd

Function LeaveComponentPage
${If} ${SectionIsSelected} ${SEC_02}
MessageBox MB_OK "blah"
${EndIf}
FunctionEnd


If you select the first section, it will show the message box. If you unselect the first section, it will not show the message box. It doesn't matter if section 2 is selected or not.

Any ideas on what goes wrong?

I already found what I did wrong: I placed the LeaveComponentPage function before the Sections. If you place the Sections first (like in the example), it works perfectly!