Archive: Install Type with specifi choicxe and hidden selection: How?


Install Type with specifi choicxe and hidden selection: How?
Hi everyone,

Purpose of my Installeur
I'm preparing an installer with the ability to install an application available in 2 versions.

Principles to follow
For each version, I have dedicated files, and dedicated settings (different network card settings for example).

I'd like to offer the user to have 2 choices only:
- Install type Development
- Install type Operation_only

For each choice, I wrote 2 dedicated sections, for which file path, settings and targets are different.

So, I have 4 sections:
- Section Development_File
- Section Development_Settings
- Section Operation_File
- Section Operation_Settings

So, for Install type Development, the user should only see the sections Development_File
& Development_Settings, the 2 others should be hidden. He can select or unselect 0, 1 or both of these 2 components. Based on the same idea, if he chooses Install type Operation_only, the 2 Development related sections will be hidden and he will be able to choose among the 2 Operation sections available only.

Problem
I spent quite some time now, reading the NSIS documentations, examples with install type, or using radio butrtons with slection/unselection macros, but I can't fin a way to properly do this. Either I see all 4 sections, or I have no selection options available... I tried also with SectionIn, but I can't figure out how it works...

So, if one of you have some remarks, comments and especially some help to provide me, I would be very happy!

Thanks in advance,
within


There's no need to hide sections, you can simply make the Op sections and Dev sections mutually exclusive.

1. Make two sectiongroups. One containing Dev_File and Dev_Settinsg, and one containing Op_File and Op_Settings. http://nsis.sourceforge.net/Docs/Chapter4.html#4.6.1.5
2. In .onInit, enable the default sections and disable the others (use the macros in Sections.nsh). Also, set a variable to store this selection state (Op or Dev).
3. In .onSelChange:

${If} $State == "Dev"
${If} ${SectionIsSelected} ${Op_File}
${OrIf} ${SectionIsSelected} ${Op_Settings}
!insertmacro UnselectSection ${Dev_File}
!insertmacro UnselectSection ${Dev_Settings}
StrCpy $State "Op"
${EndIf}
${Else}
${If} ${SectionIsSelected} ${Dev_File}
${OrIf} ${SectionIsSelected} ${Dev_Settings}
!insertmacro UnselectSection ${Op_File}
!insertmacro UnselectSection ${Op_Settings}
StrCpy $State "Dev"
${EndIf}
${EndIf}


That's all.

MSG, that looks promising.
I will look how to make section groups.
I am not sure there are real "default" sections, just Dev or Ope. If you mean, making one of these 2 as default, I guess it means it is the "on startup" selection of install type...

Thanks for your help!
Will come back when done.


Originally posted by within
If you mean, making one of these 2 as default, I guess it means it is the "on startup" selection of install type...
Yes, that's what I mean. If you want none to be selected by default, simply disable all sections and set the state variable to empty.

I am back with some feedback as promised.

Method worked perfectly as you mentioned, MSG.

To summarize, I did add the 2 sebsections:

SectionGroup "Dev"
Section "Dev_File" Dev_File
#code#
SectionEnd
Section "Dev_Settings" Dev_Settings
#code#
SectionEnd
SectionGroupEnd
SectionGroup "Op"
Section "Op_File" Op_File
#code#
SectionEnd
Section "Op_Settings" Op_Settings
#code#
SectionEnd
SectionGroupEnd


I defined a varibale to follow:
Var /GLOBAL State


and in on.Init function I added the following lines at the end to have the Dev sections to be selected by default:
  StrCpy $State "FAS HMI for Development"
!insertmacro UnselectSection ${"Op_File}
!insertmacro UnselectSection ${Op_Settings}