Archive: Dynamic SelectSection Possible?


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?


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.


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.


Use two brackets (>>) to append. See the following page for more information:

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


Actually I figured it out, I'm using !appendfile.

Thanks for you help kichik, I appreciate it.


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.