Archive: InstallTypes question


InstallTypes question
i kinda asked this question before but the result wasn't satisfying, now i thought of another way of solving my problem.

i'd like to have a dynamic installtype (autodetection of some settings), now i was wondering if it's possible to do so in a leave function.

however, the attached script doesn't work, maybe someone can help here.


This could be your problem:

StrCmp $0 "Automatic" 0 +3
!insertmacro SelectSection "1"
Abort

If you look in the SelectSection macro it contains more than one line of code, hence the +3 jump won't work. You need to use a label.

-Stu


doesn't work, when i select the installtype "automatic" nothing happens


I'm not sure exactly what you're trying to do, but InstTypeGetText 0 $0 is wrong because it should be InstTypeGetText 1 $0.

Also which section are you trying to select?
If it's the first one, then you want to SelectSection 0 not 1.

And finally, you will not notice a difference because all sections are already selected (if the two above problems are fixed).

-Stu


what i'm trying to do: i have an installer with a couple of static sections and i'd like to have a detection feature. right now i'm using a detection-feature, but the sections don't get saved. so when the user selects another installtype, the selection is gone.

the new idea was to call my detection-function in a leave function instead of doing that before the components page gets displayed. i'm not sure if it's possible, but i guess it is. i'm just a bit unexperienced with show/leave functions. not sure about the difference and the correct syntax.

so what i'm trying to do: user selects installtype "automatic" and the function detects which of my sections will be selected.


What do you need the detection feature for?
The only way to check if sections are selected is by using the SectionFlagIsSet macro (or SectionIsSelected with LogicLib).

!include Sections.nsh
...
Section "A section" SecID

!insertmacro SectionFlagIsSet ${SecID} ${SF_SELECTED} JUMPIFSET JUMPIFNOTSET

-Stu


the detection feature basically checks which features of the installer were installed. so my function uses UnselectSection to disable existing components. the current version displays a messagebox before the components page shows up, but many people don't read messageboxes anyway.. and as i said before it would be nice to jump back to that detected selection (through the installtype).

the problem right now is that the code above does absolutely nothing, when i choose "automatic" as insttype. if i get this dummy-script to work, i can easily use my existing function with it.


You can use SectionSetInstTypes. And set for all sections a necessary accessory to "Automatic" type. So installer will not "forget" a set of sections at change of InstallType.


anyone aware of an example with that command. reading the docs didn't help me understanding what exactly it does.


For example. There are 3 sections (S1,S2,S3) and 2 InstType (Full, Minimal).


SectionSetInstTypes ${S1} 3
SectionSetInstTypes ${S2} 1
SectionSetInstTypes ${S3} 1

Now Full install type contain all sections, Minimal - only first (S1).

Or next example. Check which features of the installer were installed. If component (section) was installed and you didn't want install it again - use for this section "SectionSetInstTypes sec_id 1" (if there are only 2 insttypes - All, Automatic).


this isn't exactly a good option for me, it makes my necessarily complicated - that is, if it can't be done in the way i previously proposed (but didn't get to work).

can anybody tell me, if there's a way to make it work the way i suggested?


Probably it will be most easier to write function which set necessary components for Automatic type. And in function .onSelChange call it if this type has been chosen. But i think use of the SectionSetInstTypes not such complicated.


(in my previous post there was an "un-" for unnecessarily missing)

the following problem appears when using SectionSetInstTypes:

when the installer is launched everything is fine. when i select the "onInit" installtype, the correct sections are being shown. now, when i switch back to the installtype "all", the sections selected by SectionSetInstTypes are not selected anymore.

OutFile DynSection.exe

InstType "All"
InstType "Second only"
InstType "onInit"

Page Components
Page InstFiles

Section "1" First
SectionIn 1
DetailPrint "Section 1 was selected"
SectionEnd

Section "2" Second
SectionIn 1 2
DetailPrint "Section 2 was selected"
SectionEnd

Section "3" Third
SectionIn 1
DetailPrint "Section 3 was selected"
SectionEnd

Section "4" Fourth
SectionIn 1
DetailPrint "Section 3 was selected"
SectionEnd

Function .onInit
SectionSetInstTypes ${Third} "4"
SectionSetInstTypes ${Fourth} "4"
FunctionEnd

is this a bug or a feature (if so, what is its purpose)?

That is because SectionSetInstTypes sets the install types for section with bits. For your install types max value may be 7 = 0111 (bitwise) - section is in all install types. Value 5 = 0101 (bitwise) - section is in "All" and "onInit" types. So value 4 indicate that section is only in "onInit" type (0100 bit).
This script works correctly (but i think not as it is necessary for you:D). Try to use SectionSetInstTypes ${Third} "5".


understanding it now, maybe the documentation should at least give 2 examples for better comprehension. thanks glory_man!