Archive: Conditional (radiobutton) extraction of installer (packed) files


Conditional (radiobutton) extraction of installer (packed) files
Hi all!

Cannot find right solution for my needs.

I have such source dir structure:
- dir1
- dir2
- dir3

They all have the same folders structure and filenames inside.

I want each of them to be included in installer but extracted (only one) with regard to the user-selected radio button.


I suppose they have same structure/names but they are different and installed regarding to specific os, (e.g. if os is xp install dir1 etc), or a similar short of thing.

If this is the case you need to add them in separate sections and dynamically activate the section which is going to be installed according to checked radio button.


installed regarding to specific os
No, I`ve written that it`s with regard to selected radiobutton.

to add them in separate sections and dynamically activate the section which is going to be installed according to checked radio button.
Can you provide some clue, code snippet?

They all have the same folders structure and filenames inside.
Sorry but I can't get the point unless they serve different target environment conditions...

Anyway, these links might help you start,

http://forums.winamp.com/showthread....hreadid=264357

http://forums.winamp.com/showthread....hreadid=263822

Actually it doesn`t matter whether they have the same structure or not.
Lets say I have some set of skins for some software packages.
User selects which software he/she wants to install skins for, and only those skins should be installed. Not all of them. But they all still have to be included in a single installer.
For now I have ID of radiobutton selected, but what to do next?

And how can I make such thing in NSIS:
if (var == value)
{
....
}
else
{
....
}

or

switch (var)
{
case value :
{
....
}
}


Is this not just a case of using different directory depending on section selection ?

There is an example in the nsis examples dir called one-section.nsi

; one-section.nsi
;
; This example demonstrates how to control section selection.
; It allows only one of the sections of a group to be selected.

;--------------------------------

; Section define/macro header file
; See this header file for more info

!include "Sections.nsh"

;--------------------------------

Name "One Section"
OutFile "one-section.exe"

;--------------------------------

; Pages

Page components

;--------------------------------

; Sections

Section !Required
SectionIn RO
SectionEnd

Section "Group 1 - Option 1" g1o1
SectionEnd

Section /o "Group 1 - Option 2" g1o2
SectionEnd

Section /o "Group 1 - Option 3" g1o3
SectionEnd

Section "Group 2 - Option 1" g2o1
SectionEnd

Section /o "Group 2 - Option 2" g2o2
SectionEnd

Section /o "Group 2 - Option 3" g2o3
SectionEnd

;--------------------------------

; Functions

; $1 stores the status of group 1
; $2 stores the status of group 2

Function .onInit

StrCpy $1 ${g1o1} ; Group 1 - Option 1 is selected by default
StrCpy $2 ${g2o1} ; Group 2 - Option 1 is selected by default

FunctionEnd

Function .onSelChange

!insertmacro StartRadioButtons $1
!insertmacro RadioButton ${g1o1}
!insertmacro RadioButton ${g1o2}
!insertmacro RadioButton ${g1o3}
!insertmacro EndRadioButtons

!insertmacro StartRadioButtons $2
!insertmacro RadioButton ${g2o1}
!insertmacro RadioButton ${g2o2}
!insertmacro RadioButton ${g2o3}
!insertmacro EndRadioButtons

FunctionEnd


I had to do something similar with my installer where depending on selection only 2 files are different so i set the varying files in the sections and call a function to run the common instructions.
In my case some stripping out of the above code was required - but it works a treat with MUI.


Hope that helps :)

I have attached a screenshot of the outcome - and can supply the code if this is what you mean..


Yes, that`s it. Please.


Something like the following :


!include "mui.nsh"
!include "Sections.nsh"


Name "Version selecter"
OutFile "version.exe"

;pages

!insertmacro MUI_PAGE_COMPONENTS

;functions

Function CommonFilesFunction
Sleep 4000
; Do common Stuff
FunctionEnd

;Sections

###################################
Section "Version 1" g1o2

SetOutPath "c:\install"
;file version1.blah
;file version1a.blah

Call CommonFilesFunction ; Fuction to do the common stuff

SectionEnd
####################################
Section "Version 2" g1o3

SetOutPath "c:\install"
;file version2.blah
;file version2a.blah

Call CommonFilesFunction ; Fuction to do the common stuff

SectionEnd
####################################
Section "Version 3" g1o4

SetOutPath "c:\install"
;file version3.blah
;file version3a.blah

Call CommonFilesFunction ; Fuction to do the common stuff

SectionEnd
####################################


Function .onSelChange

!insertmacro StartRadioButtons $1
!insertmacro RadioButton ${g1o2}
!insertmacro RadioButton ${g1o3}
!insertmacro RadioButton ${g1o4}
!insertmacro EndRadioButtons

FunctionEnd



You don't need a common files function there - just use a hidden section by prefixing the section name with a dash.

-dandaman32