Old 7th June 2016, 14:24   #1
Junior Member
Join Date: Jun 2016
Posts: 2
Programmatically Select Sections Based on Dialog Choices?

Is it possible to programmatically select sections based on page/dialog choices?

Here's a minimal working example of something I'm trying:


!include Sections.nsh

Name "select1"
OutFile "select1.exe"
InstallDir C:\mwe
RequestExecutionLevel user

Page directory prior
Page instfiles

Function prior
!insertmacro SelectSection Level1A

Section ""
MessageBox MB_OK "Common Install"

Section /o "Level 1 A" Level1A
MessageBox MB_OK "Level 1 A"

Why isn't section "Level1A" ever happening? If I remove the "/o", it happens. I can insert a messagebox into "prior" and verify that it is being invoked. The docs say to use something like "${Level1A}" in the SelectSection macro, but tho NSIS compiler just complains:

unknown variable/constant "{Level1A}" detected, ignoring (macro:SelectSection:4)
I assume I'm approaching the problem incorrectly. What's wrong with what I'm doing?
mojomojomojo is offline   Reply With Quote
Old 7th June 2016, 14:57   #2
Afrow UK
Afrow UK's Avatar
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
As the warning shows you, Level1A is not defined when you use it. You need to move your callback function after the section in your script.

Edit: Also it should be !insertmacro SelectSection ${Level1A} but going by that warning message, that's what you have put in your actual script

Afrow UK is offline   Reply With Quote
Old 7th June 2016, 21:45   #3
Junior Member
Join Date: Jun 2016
Posts: 2
Thanks. I didn't realize order was important. Perhaps I missed the part of the docs that distinguished between macros and variables and which components use what.
mojomojomojo is offline   Reply With Quote
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

select section

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump