- NSIS Discussion
- Easy one for you Pros
Archive: Easy one for you Pros
dive2xs
26th January 2006 08:02 UTC
Easy one for you Pros
Ok I have been searching but it is getting late, and I have not been able to adapt the examples and get them to work.
Here is what i need.
I have 2 programs that do the same thing. The Ethernet version has 1 exe file we will call "A". The serial version needs 2 exe files we will cal "B" & "C". However "B" and "C" are both requires fr the second version they can be installed on two seperate computers.
I need to allow the following 4 options.
Install "A" only
Install "B" only
Install "C" only
or
Install "B" and "C" only
Comm@nder21
26th January 2006 15:48 UTC
see Sections.nsh :)
dive2xs
27th January 2006 01:11 UTC
OK this is what I have and where I am stumped.
;Installer Sections
Section /o "Ethernet Connection" Sec1
SectionEnd
SectionGroup "Serial Connection" Sec2
Section /o "Server" Sec3
SectionEnd
Section /o "Client" Sec4
SectionEnd
SectionGroupEnd
;--------------------------------
;Functions
Function .onSelChange
!insertmacro StartRadioButtons $1
!insertmacro RadioButton ${Sec1}
!insertmacro RadioButton ${Sec2}
!insertmacro RadioButton ${Sec3}
!insertmacro RadioButton ${Sec4}
!insertmacro EndRadioButtons
FunctionEnd
So the problem is if the user selects the serial connection and then changes to select the Ethernet version, one of the serial components stay selected.
So the only allowable options should be
Sec1 or Sec2(Sec3+Sec4) or Sec3 or Sec4.
The second problem I noticed is if you de-select one of the Serial subgroups and try to reselect it, it basically flip flops. The only way to reselect it is to select the ethernet version and then select the serial version again.
Any and all help is greatly appreciated.
kichik
27th January 2006 14:37 UTC
You shouldn't put Sec2 in the radio buttons list because it's a section group.
dive2xs
27th January 2006 17:42 UTC
OK, but that does not make any change in the behavior of the buttons.
Afrow UK
28th January 2006 10:46 UTC
RadioButtons will not work here. You'll need some custom code to do it. I'll make some for you later today when I get back from January shopping :)
Sorry I haven't replied to your Private Messages either. It was my 18th birthday on Friday and I tend to stay away from the computer on and around my birthdays ;)
-Stu
dive2xs
28th January 2006 21:47 UTC
Hey no problem. I appreciate the help, Happy 18th! Do you get to enjoy spirits at that age in England?
If so, Congrats and I would be jealous if I was 18 again!
Afrow UK
29th January 2006 10:30 UTC
Yep you can legally drink at 18 here in the UK!
Try this compilable script:
!include MUI.nsh
!include Sections.nsh
OutFile dive2xs.exe
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE English
Var T
;Installer Sections
Section /o "Ethernet Connection" Sec1
SectionEnd
SectionGroup "Serial Connection" SecGrp1
Section /o "Server" Sec2
SectionEnd
Section /o "Client" Sec3
SectionEnd
SectionGroupEnd
Function .onInit
StrCpy $T 0
FunctionEnd
Function .onSelChange
Push $R0
SectionGetFlags ${Sec1} $R0
IntOp $R0 $R0 & ${SF_SELECTED}
StrCmp $R0 ${SF_SELECTED} 0 NoUnselectSec1
StrCmp $T ${Sec1} NoUnselectSec1
StrCpy $T ${Sec1}
!insertmacro UnselectSection ${SecGrp1}
Goto End
NoUnselectSec1:
SectionGetFlags ${Sec2} $R0
IntOp $R0 $R0 & ${SF_SELECTED}
StrCmp $R0 ${SF_SELECTED} 0 NoUnselectSec2
StrCmp $T ${Sec2} NoUnselectSec3
StrCpy $T ${Sec2}
Goto UnselectSec1
NoUnselectSec2:
SectionGetFlags ${Sec3} $R0
IntOp $R0 $R0 & ${SF_SELECTED}
StrCmp $R0 ${SF_SELECTED} 0 NoUnselectSec3
StrCmp $T ${Sec3} NoUnselectSec3
StrCpy $T ${Sec3}
UnselectSec1:
!insertmacro UnselectSection ${Sec1}
NoUnselectSec3:
End:
Pop $R0
FunctionEnd
-Stu
dive2xs
29th January 2006 18:55 UTC
Man, You rock! Where can I make a donation?
dive2xs
30th January 2006 03:16 UTC
Can I bother you for another need. I would be happy to compensate you...
I need the ability if the choose the Sec2 I need to record an option in the registry.
WriteRegStr HKLM SOFTWARE\program "ComPort" "comx"
However I need them to specify which com port they are using. and then modify the "comx" to linke "com5"
Afrow UK
30th January 2006 08:48 UTC
Uhm, that won't be necessary but if you're offering I don't mind :) Paypal: bikube at tiscali.co.uk
For getting user input you can use my PassDialog plugin which has a basic dialog with a single input box. Something like this:
LangString ${LANG_ENGLISH} BAD_PORT_NUM "Please enter a valid port number!"
Page Custom GetPort GetPortLeave
Function GetPort
PassDialog::Dialog inputbox /HEADINGTEXT "Enter port number..." /GROUPTEXT "Serial number"
Pop $R0 # success, back, cancel, error
FunctionEnd
Function GetPortLeave
Pop $R0 # User input string.
# User entered nothing!
StrCmp $R0 "" 0 +3
MessageBox MB_OK|MB_ICONSTOP $(BAD_PORT_NUM)
Abort
# Check that string is number only.
Push "0123456789"
Push $R0
Call StrCSpn
Pop $R1
StrCmp $R1 "" +3
MessageBox MB_OK|MB_ICONSTOP $(BAD_PORT_NUM)
Abort
# Write port number to registry.
WriteRegStr HKLM "SOFTWARE\program" "ComPort" "com$R1"
FunctionEnd
You need the
StrCSpnReverse function for this code too.You can download my PassDialog plugin from:
http://nsis.sf.net/File:PassDialog.zip
-Stu
dive2xs
30th January 2006 19:29 UTC
SO how do I make it so this only works when the server (Sec2) is selected.
Otherwise it looks good.
dive2xs
30th January 2006 19:37 UTC
Also got this warning:
LangString "BAD_PORT_NUM" is not set in language table of language English
Afrow UK
30th January 2006 21:10 UTC
Oops sorry, LangString parameters order was incorrect. Should be:
LangString BAD_PORT_NUM ${LANG_ENGLISH} "Please enter a valid port number!"
To only show the dialog if Sec2 is selected, simply jump over the plugin call:
Function GetPort
SectionGetFlags ${Sec2} $R0
IntOp $R0 $R0 & ${SF_SELECTED}
StrCmp $R0 ${SF_SELECTED} 0 SkipPage
PassDialog::Dialog inputbox /HEADINGTEXT "Enter port number..." /GROUPTEXT "Serial number"
Pop $R0 # success, back, cancel, error
SkipPage:
FunctionEnd
-Stu
dive2xs
30th January 2006 22:19 UTC
Thanks