Skip to content
⌘ NSIS Forum Archive

Question about SectionGetFlags

4 posts

Mircea M#

Question about SectionGetFlags

Hi,

I have the following structure in my installer:

Section /o "Automatic Drive Partitioning" SEC_PART
${myLogText} "**** Automatic Drive Partitioning ****"
Call startPartitioner
Call readPartitionerLog
SectionEnd

Section /o "Modify Windows Settings" SEC_WIN
${myLogText} "**** Windows Settings Configuration ****"
Call instWin
SectionEnd
In a separate file called Dialogs.nsi, I have defined some functions that display custom pages. These pages are only to be displayed if a certain section is selected. In order to do this, I use something like this:

Function preWin
SectionGetFlags 1 $R0
IntOp $R0 $R0 & ${SF_SELECTED}
IntCmp $R0 ${SF_SELECTED} show

Abort

show:
...
FunctionEnd
Thus, if section SEC_WIN is selected, I would see the function that starts with the above code.

My "problem" is that if I have to add a new section and I want it to appear before an existing one, I would have to modify my Dialogs.nsi every time to update the section index.

In order to avoid this, I tried using the section ID instead of the index, as such:

Function preWin
SectionGetFlags ${SEC_WIN} $R0
IntOp $R0 $R0 & ${SF_SELECTED}
IntCmp $R0 ${SF_SELECTED} show

Abort

show:
...
FunctionEnd
Problem is, when I do this, I get a compile error stating that:
warning: unknown variable/constant "{SEC_VID}" detected, ignoring (Dialogs.nsi:50)
Usage: SectionGetFlags section_index $(user_var: output flags)

I suppose this is because the Dialogs.nsi file is included before my sections are defined and as such, the variables ${SEC_WIN}, etc. don't exist yet. Is there any way to avoid using the section index numbers and use the identifiers instead?

Thanks,
Mircea
Mircea M#
Ok, I needed to change some things around there (had also some variables declared) but this works. Thanks for the simple solution!
Anders#
If you don't want to move things around in the include file you could put the code that uses the section ids in a macro, this allows you to include the file early and insert the macro after the sections...