Old 7th February 2006, 17:50   #1
flyakite
Member
 
Join Date: Dec 2003
Location: Chicago
Posts: 50
Send a message via AIM to flyakite Send a message via Yahoo to flyakite
Dynamic SelectSection Possible?

I have a tool with over 200 sections, each representing a particular file that can be installed.

I would like to be able to dynamically enable sections via the command line, by calling the tool with "/file1 /file25" etc.

I use GetNextParameters and all that to read the values of each parameter on the command line and have no problem with that. The problem is then trying to call !insertmacro SelectSection. It does not work, due to the fact that I am reading the parameters and storing them as a variable, and then trying to pass that variable to SelectSection, which seems to need a define.

Is there any way I can do this, without doing 200 StrCmps and having a line of code for each SelectSection indexname?
flyakite is offline   Reply With Quote
Old 7th February 2006, 17:53   #2
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
You can use LogicLib's ${Switch} instead of 200 StrCmp, or you can create some mapping file. You can also create the switch dynmically while compiling the script. Write a little macro that'll write one line of the switch (using !system 'echo something > somefile') and insert that macro for every section. You can even have that macro both define the section and update the file.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 7th February 2006, 18:13   #3
flyakite
Member
 
Join Date: Dec 2003
Location: Chicago
Posts: 50
Send a message via AIM to flyakite Send a message via Yahoo to flyakite
Well I have it partially working. I'm testing it based off of the command in the user manual:

!system 'echo !define test > newinclude.nsh'

However, the file newinclude.nsh just gets overwritten with "!define test" for every section, instead of the line getting appended, and I can't figure out how to make it just keep adding to the file.
flyakite is offline   Reply With Quote
Old 7th February 2006, 18:16   #4
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
Use two brackets (>>) to append. See the following page for more information:

http://www.robvanderwoude.com/index.html

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 7th February 2006, 18:16   #5
flyakite
Member
 
Join Date: Dec 2003
Location: Chicago
Posts: 50
Send a message via AIM to flyakite Send a message via Yahoo to flyakite
Actually I figured it out, I'm using !appendfile.

Thanks for you help kichik, I appreciate it.
flyakite is offline   Reply With Quote
Old 7th February 2006, 18:20   #6
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
Right, that's actually better because it'll work on Linux and friends. Sorry, forgot about it.

BTW, LogicLib.nsh uses these instructions to create the code for ${Switch}. You can take a look at it for an example.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

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