- NSIS Discussion
- Custom page problem...
Archive: Custom page problem...
Theresias
9th October 2006 15:20 UTC
Custom page problem...
I'm having a custom page with 2 radiobuttons, from which I need to read the status.
SelectInterfacePage
>!insertmacro MUI_HEADER_TEXT "$(SelectInterface_TITLE)" "$(SelectInterface_SUBTITLE)"
>!insertmacro MUI_INSTALLOPTIONS_DISPLAY "SelectInterface.ini"
>!insertmacro MUI_INSTALLOPTIONS_READ $USB "SelectInterface" "Field 2" "State"
>!insertmacro MUI_INSTALLOPTIONS_READ $COM "SelectInterface" "Field 3" "State"
>FunctionEnd
>
Comes up with...
MUI_INSTALLOPTIONS_READ
Usage
: ReadINIStr $(user_var: output) ini_file section entry_name
Error in macro MUI_INSTALLOPTIONS_READ on macroline 5
Error in script"D:\Installer\TEST.nsi" on line 78 -- aborting creation process
>
Any ideas?
saschagottfried
9th October 2006 16:57 UTC
just use full file name like "SelectInterface.ini" as you do in "display" macro. That's all.
Excerpt from NSIS help: Using InstallOptions for custom pages
insertmacro MUI_INSTALLOPTIONS_DISPLAY "ioFile.ini"
Use these macros to read or write INI file values:
!insertmacro MUI_INSTALLOPTIONS_READ $VAR "ioFile.ini" "Field #" "Name"
!insertmacro MUI_INSTALLOPTIONS_WRITE "ioFile.ini" "Field #" "Name" "Value"
For example, you can use the MUI_INSTALLOPTIONS_READ macro in a section to get the user input:
!insertmacro MUI_INSTALLOPTIONS_READ $R0 "ioFile.ini" "Field 1" "State"
For more details about InstallOptions, validation of user input etc., check the InstallOptions documentation.
Afrow UK
9th October 2006 17:25 UTC
Did you declare the variables $USB and $COM with the Var instruction? Just use $R0 and $R1 instead (save on memory usage).
-Stu
Theresias
9th October 2006 18:06 UTC
Originally posted by saschagottfried
just use full file name like "SelectInterface.ini" as you do in "display" macro. That's all.
That didn't change anything.
Originally posted by saschagottfried
For more details about InstallOptions, validation of user input etc., check the InstallOptions documentation.
This was my plan, sadly SF.net was unaccessible for the time being.
Originally posted by Afrow UK
Did you declare the variables $USB and $COM with the Var instruction? Just use $R0 and $R1 instead (save on memory usage).
You got it! Thank you, that solved it.
JasonFriday13
10th October 2006 01:26 UTC
And, ideally, the code should be split up like this:
Page Custom SelectInterfacePage SelectInterfacePageLeave
Function SelectInterfacePage
!insertmacro MUI_HEADER_TEXT "$(SelectInterface_TITLE)" "$(SelectInterface_SUBTITLE)"
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "SelectInterface.ini"
FunctionEnd
Function SelectInterfacePageLeave
!insertmacro MUI_INSTALLOPTIONS_READ $USB "SelectInterface" "Field 2" "State"
!insertmacro MUI_INSTALLOPTIONS_READ $COM "SelectInterface" "Field 3" "State"
FunctionEnd
Theresias
10th October 2006 12:12 UTC
Thanks Jason, I tried that and this is what I have now:
Function SelectInterfacePageLeave
# Read USB ($R0)
!insertmacro MUI_INSTALLOPTIONS_READ $R0 "SelectInterface" "Field 2" "State"
# Read COM ($R1)
!insertmacro MUI_INSTALLOPTIONS_READ $R1 "SelectInterface" "Field 3" "State"
StrCmp $R0 "1" USB COM
USB:
MessageBox MB_OK "USB ausgewählt! USB: $R0 COM: $R1"
COM:
MessageBox MB_OK "COM ausgewählt! USB: $R0 COM: $R1"
FunctionEnd
Problem now is, whatever I select, it ends up with using "COM", so I tried to use the MBox to give me the current values of $R0 and $R1, but both are empty. Any ideas?
JasonFriday13
11th October 2006 00:05 UTC
Try putting the extension on the file being read:
!insertmacro MUI_INSTALLOPTIONS_READ $R0 "SelectInterface.ini" "Field 2" "State"
Theresias
11th October 2006 09:19 UTC
Again, thanks!
saschagottfried
11th October 2006 10:35 UTC
...and you have to skip the "COM" label, when condition "USB" is met. I don't know if you have not figured out this yet.
see this example from NSIS help:
StrCmp $0 "a string" 0 +3
DetailPrint '$$0 == "a string"'
Goto +2
DetailPrint '$$0 != "a string"'
my advice: include LOGIGLIB.nsh and this will never happen. A great tool especially for beginners with NSIS.
JasonFriday13
11th October 2006 22:17 UTC
Like this:
Function SelectInterfacePageLeave
# Read USB ($R0)
!insertmacro MUI_INSTALLOPTIONS_READ $R0 "SelectInterface.ini" "Field 2" "State"
# Read COM ($R1)
!insertmacro MUI_INSTALLOPTIONS_READ $R1 "SelectInterface.ini" "Field 3" "State"
StrCmp $R0 "1" USB COM
USB:
MessageBox MB_OK "USB ausgewählt! USB: $R0 COM: $R1"
GoTo EndIf
COM:
MessageBox MB_OK "COM ausgewählt! USB: $R0 COM: $R1"
EndIf:
FunctionEnd
Theresias
11th October 2006 22:39 UTC
Thanks guys! Works perfectly now.