Archive: Use section index in .nsh header file?


Use section index in .nsh header file?
As the question says: I´m trying to use the section index in a .nsh file which configures pages and includes custom pages. I´m trying to do so with the function SectionSetInstTypes.

When I try to get the INST Type with SectionGetInstTypes it´s not working the output is always 7.

This is my code in the header file for the inst type:

SectionSetInstTypes ${Section2} 1
SectionGetInstTypes ${Section2} $R4
messagebox mb_ok "$R4"


Is there no or any possibility to get the index in the .nsh files?


So far it seems i can´t use the index because the include is called before the section is declared. But what now? how can I change the InstType while runtime. I´ve got a checkbox on a custom page and depending on this box this section will or will not be installed. (Additonal to the InstType)

Any suggestions?


Include the nsh later, or put the section manipulation into a function that is defined after the sections.


I´m totally stuck!
If I include the header, function whatever after the section where I wanna change the selection that means the installation already happens and it has no effect!?

If I wanna change the InstType of a section while runtime then I need to do that in the leave function of the custom page...circle of death :mad:

I don´t know how to solve this problem I tried to define a variable which represents the InstType in my header...works so far but only with one InstType because the defines are called even if they are in a normal if. So the first if will overwrite the second one. And I can´t figure out how to set !ifdef and !ifndef in the code. :igor:


I'm not seeing what it is you're trying to do, what nsh you are including.

I think you want to create custom pages, and with checkboxes or radio buttons or whatever, let the user choose some options. Those options would then control (enable / disable) Sections that do the actual installation and configuration to meet the user needs.

Here's an outline of the order your nsi should have:
use !define to create strings for registry keys, program name, etc so future updates are easier
include the nsh headers at the top of the file.
define the installer attributes (name, compressor, execution level, etc)
reserve files (if using solid compression)
define the pages (standard and custom)
define/code the sections
define the language strings (if you use MUI2) for section titles and subtitles
code callback functions .onInit, etc
code page functions (pre/show/leave)
code functions called from the sections

The nsis compiler is just one pass. Except for functions you call, nearly everything must have been compiled before you can write code that references it. Putting functions after all the sections allows the section ids to be defined, and should allow you to set or reset them even though at runtime the page leave code that has called the function was higher in the script than the sections.

Don


Solved...

My problem was that my function in my nsh file could not find the section index. This nsh includes every configuration for the pages and custom pages.

I solved the problem with a not very nice solution as I think. I included the leave function from my nsh file after the sections in my main file. Problem solved because the function recognized the section index. But it´s not very good for any maintenance!