Archive: installoptions dropdown question


installoptions dropdown question
Hi I would like to assign values to the InstallOptions dropdown menus


[Please select a menu item] (value=0)
Brazil mirror (value=http://www.br)
Swedish mirror (value=http://www.se)


I would imagine the code would look something like this:


[Field 3]
Type=DropList
ListItems=a|b|c
ListValues=0|1|2
Left=10
Right=230
Top=20
Bottom=30
State=a


notice the ListValues?

does something like that exist?

!define item1 "0"
!define item2 "1"

on custom leave function
readinistr $R0 '$PLUGINSDIR\custom.ini' 'Field 3' 'State'
${If} $R0 == 'a'
# use the ${item1} the way you imagine to use it
${ElseIf} $R0 == 'b'
# use the ${item2} the way you imagine to use it
${EndIf}


wow, I thought I had thought about that...

I got it to work now, not exactly like that, but kind of :) thanks


Originally posted by Red Wine
!define item1 "0"
!define item2 "1"

on custom leave function
readinistr $R0 '$PLUGINSDIR\custom.ini' 'Field 3' 'State'
${If} $R0 == 'a'
# use the ${item1} the way you imagine to use it
${ElseIf} $R0 == 'b'
# use the ${item2} the way you imagine to use it
${EndIf}
I have been able to find a lot of information for a lot of other things this installer I am working on needs to do for me, so I thank you very much for the robust search here at this board and at the wiki. The search results in my latest hurdle only seem to show a few possible solutions, and then to my dismay some without actually mentioning what "fixed" the issue. Lol. I have been trying to find further information as the above is pretty much what I am looking for.

I too am looking to have a drop down box using an InstallOptions MUI custom page with multiple selections to select a ListItem from the menu and pass the ListValue ID# to the leave page that then writes the ID# to a configuration file (config.xml) that is installed in the installation directory.

The first step, of course, is to get the drop down menu ini to show all options(there are almost 100 of them) and have an assigned ID# to each option. Do I have to create 100 entires? (example item1|item2|item3~|Item99 ). If so, that
is ok.

However, how do I then read from the ListValue without having to create a line of code in the script to define each item 0-99 and then have 99 ElseIf statements as is given above with the much smaller list above as an example graciously given by Red Wine?

It'd be messy to do each item, but I suppose it would work :D . I just hope that I wont have to do that though.

I am grocking a much as I can in a short period, but NSIS is almost it's own language. Which is very cool. I love how versatile this is. So what would you all recommend?

hopefully this would help,

!define EN_SERVER "http://www.eng.com"
!define ES_SERVER "http://www.esp.es"
!define RU_SERVER "http://www.rus.ru"

var server

showinstdetails show
outfile 'test.exe'
Installdir "$PROGRAMFILES\My Application"

!include logiclib.nsh

page custom customcreate customleave
page directory
page instfiles

section
DetailPrint "Downloading from $server"
sectionend

function customleave
ReadINIStr $0 "$PLUGINSDIR\custom.ini" "settings" "state"
${If} $0 == 0
ReadINIStr $0 "$PLUGINSDIR\custom.ini" "field 2" "state"
${AndIf} $0 == "Select Server"
MessageBox MB_OK "Please select a server"
Abort
${EndIf}
ReadINIStr $0 "$PLUGINSDIR\custom.ini" "field 2" "state"
${If} $0 == "English Server"
StrCpy $server "${EN_SERVER}"
${elseif} $0 == "Spanish Server"
StrCpy $server "${ES_SERVER}"
${else}
StrCpy $server "${RU_SERVER}"
${EndIf}
functionend

function customcreate
InstallOptions::Dialog "$PLUGINSDIR\custom.ini"
pop $0
functionend

function .onInit
InitPluginsDir
WriteIniStr "$PLUGINSDIR\custom.ini" "settings" "numfields" "2"

WriteIniStr "$PLUGINSDIR\custom.ini" "field 1" "type" "groupbox"
WriteIniStr "$PLUGINSDIR\custom.ini" "field 1" "left" "0"
WriteIniStr "$PLUGINSDIR\custom.ini" "field 1" "right" "-1"
WriteIniStr "$PLUGINSDIR\custom.ini" "field 1" "top" "10"
WriteIniStr "$PLUGINSDIR\custom.ini" "field 1" "bottom" "-11"
WriteIniStr "$PLUGINSDIR\custom.ini" "field 1" "text" "Select server"

WriteIniStr "$PLUGINSDIR\custom.ini" "field 2" "type" "droplist"
WriteIniStr "$PLUGINSDIR\custom.ini" "field 2" "left" "40"
WriteIniStr "$PLUGINSDIR\custom.ini" "field 2" "right" "-40"
WriteIniStr "$PLUGINSDIR\custom.ini" "field 2" "top" "30"
WriteIniStr "$PLUGINSDIR\custom.ini" "field 2" "bottom" "80"
WriteIniStr "$PLUGINSDIR\custom.ini" "field 2" "Listitems" "Select Server|English Server|Spanish Server|Russian Server"
WriteIniStr "$PLUGINSDIR\custom.ini" "field 2" "state" "Select Server"
functionend