lardus
8th April 2005 11:28 UTC
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
glory_man
8th April 2005 14:29 UTC
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).
Afrow UK
8th April 2005 15:21 UTC
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
    
      oldfox
      8th April 2005 15:34 UTC
      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.
     
    
      glory_man
      8th April 2005 15:34 UTC
      Affrow, your example easier and more proper.
     
    
      Afrow UK
      8th April 2005 15:39 UTC
      Use the SelectSection and UnselectSection macro's in Sections.nsh...
      
      For example:
      !include Sections.nsh
      
      !insertmacro SelectSection ${SecID}
      
      -Stu
     
    
      glory_man
      8th April 2005 15:40 UTC
      Did you want to uncheck section?
     
    
      lardus
      8th April 2005 15:56 UTC
      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
     
    
      lybra
      22nd June 2006 11:10 UTC
      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?
    
 
    
      lybra
      22nd June 2006 11:20 UTC
      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!