开发者

NSIS: check if section in sectiongroup is selected

I have a NSIS script with a number of sections an开发者_如何学运维d a section group. This is purely for display purposes, e.g.:

SectionGroup /e "ERP Integration"
    Section /o "Exact" SEC_EXACT
        ; section stuff
    SectionEnd

    Section /o "Navision" SEC_NAV
        ; section stuff
    SectionEnd
SectionGroupEnd

Now, I want to check if a particular subsection is selected. You have the Sections.nsh header with some nifty macro's for that, so I tried:

    !insertmacro SectionFlagIsSet ${SEC_NAV} ${SF_SELECTED} End${ProductName} ""
        StrCpy ${ConfigProductVar} "true"
        StrCpy ${ConfigGlobalVar} "true"
        nsislog::log "$INSTDIR\install.log" "${ProductName} is not yet installed and selected, call config"
    End${ProductName}:

However, this returns true if one of the subsections in a group is selected.

Is there a way to check if a particular section in a group is selected, without interference from other sections in the group?


The code you have posted should work correctly for a single section inside a section group. The only problem I can see could be if the SectionFlagIsSet ${SEC_NAV}... code appears before the actual sections in you .nsi. The defines for the section index (SEC_EXACT,SEC_NAV) are not defined until the section command is processed, so ${SEC_NAV} would not be a valid number, SectionFlagIsSet would probably process that as 0 and that is your section group.

You should also switch to the logic lib so the code would look like:

${If} ${SectionIsSelected} ${SEC_NAV}
;....
${Else}
;....
${EndIf}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜