Archive: Setting custom page values...


Setting custom page values...
I used the test.nsi example script to create a custom page with a set of radio buttons. I then added command line arguments (what respectable installer would be without this capability). I am successfully collecting the command line arguments, but having trouble setting any values in the custom screen.

I am trying the following in .oninit:
StrCmp $LocationCmdLine "A" 0 +6
WriteINIStr $PLUGINSDIR\options.ini "Field 2" "State" 1
WriteINIStr $PLUGINSDIR\options.ini "Field 3" "State" 0
WriteINIStr $PLUGINSDIR\options.ini "Field 4" "State" 0
InstallOptions::dialog "$PLUGINSDIR\options.ini"
MessageBox MB_OK "Just set Location to A"
StrCmp $LocationCmdLine "B" 0 +6
WriteINIStr $PLUGINSDIR\options.ini "Field 2" "State" 0
WriteINIStr $PLUGINSDIR\options.ini "Field 3" "State" 1
WriteINIStr $PLUGINSDIR\options.ini "Field 4" "State" 0
InstallOptions::dialog "$PLUGINSDIR\options.ini"
MessageBox MB_OK "Just set Location to B"
StrCmp $LocationCmdLine "C" 0 +6
WriteINIStr $PLUGINSDIR\options.ini "Field 2" "State" 0
WriteINIStr $PLUGINSDIR\options.ini "Field 3" "State" 0
WriteINIStr $PLUGINSDIR\options.ini "Field 4" "State" 1
InstallOptions::dialog "$PLUGINSDIR\options.ini"
MessageBox MB_OK "Just set Location to C"

What am I missing here?

Also, when I run this silently what happens to the values in this screen? Do I need to add extra code to propogate these values, or will the default get selected as I am hoping?

Thanks,

-Kevin


Hard to tell what's wrong without knowing what actually happens. The code seems fine so I don't see what kind of trouble you're talking about.

You should use LogicLib instead of StrCmp. The code be clearer and simpler.

!include LogicLib.nsh
#...
${If} $LocationCmdLine == A
WriteINIStr $PLUGINSDIR\options.ini "Field 2" State 1
# ...
${ElseIf} $LocationCmdLine == B
WriteINIStr $PLUGINSDIR\options.ini "Field 2" State 0
# ...
${ElseIf} $LocationCmdLine == C
WriteINIStr $PLUGINSDIR\options.ini "Field 2" State 0
# ...
${EndIf}
InstallOptions::dialog $PLUGINSDIR\options.ini
As for silent installers, this code will not be executed. This means the INI will just stay the way it is.

Use LogicLib.

Also, you don't need 3 calls to the plug-in.

Stu


I got it. I had the following lines after my check...

InitPluginsDir
File /oname=$PLUGINSDIR\options.ini "options.ini"

Oops, my bad. I moved them to be before my check and all is now well. Thanks for the code suggestions, too.

I am not sure what was meant by not needing three calls to the plugin, but if you set more than one radio button value to 1, it sets more than 1 button to on.

-Kevin