Go Back   Winamp Forums > Developer Center > NSIS Discussion

Reply
Thread Tools Search this Thread Display Modes
Old 26th January 2006, 07:02   #1
dive2xs
Junior Member
 
Join Date: Jul 2005
Posts: 14
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
dive2xs is offline   Reply With Quote
Old 26th January 2006, 14:48   #2
Comm@nder21
Major Dude
 
Join Date: Jul 2003
Location: germany, b-w
Posts: 734
Send a message via ICQ to Comm@nder21
see Sections.nsh
Comm@nder21 is offline   Reply With Quote
Old 27th January 2006, 00:11   #3
dive2xs
Junior Member
 
Join Date: Jul 2005
Posts: 14
OK this is what I have and where I am stumped.

code:

;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.
dive2xs is offline   Reply With Quote
Old 27th January 2006, 13:37   #4
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,337
You shouldn't put Sec2 in the radio buttons list because it's a section group.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 27th January 2006, 16:42   #5
dive2xs
Junior Member
 
Join Date: Jul 2005
Posts: 14
OK, but that does not make any change in the behavior of the buttons.
dive2xs is offline   Reply With Quote
Old 28th January 2006, 09:46   #6
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Birmingham, England
Posts: 8,202
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

Need an installer? http://www.afrowsoft.co.uk
Afrow UK is offline   Reply With Quote
Old 28th January 2006, 20:47   #7
dive2xs
Junior Member
 
Join Date: Jul 2005
Posts: 14
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!
dive2xs is offline   Reply With Quote
Old 29th January 2006, 09:30   #8
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Birmingham, England
Posts: 8,202
Yep you can legally drink at 18 here in the UK!
Try this compilable script:
code:

!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

Need an installer? http://www.afrowsoft.co.uk
Afrow UK is offline   Reply With Quote
Old 29th January 2006, 17:55   #9
dive2xs
Junior Member
 
Join Date: Jul 2005
Posts: 14
Man, You rock! Where can I make a donation?
dive2xs is offline   Reply With Quote
Old 30th January 2006, 02:16   #10
dive2xs
Junior Member
 
Join Date: Jul 2005
Posts: 14
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"
dive2xs is offline   Reply With Quote
Old 30th January 2006, 07:48   #11
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Birmingham, England
Posts: 8,202
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:

code:

LangString ${LANG_ENGLISH} BAD_PORT_NUM "Please enter a valid port number!"

Page Custom GetPort GetPortLeave

Function GetPort
PassDialog:ialog 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

Need an installer? http://www.afrowsoft.co.uk
Afrow UK is offline   Reply With Quote
Old 30th January 2006, 18:29   #12
dive2xs
Junior Member
 
Join Date: Jul 2005
Posts: 14
SO how do I make it so this only works when the server (Sec2) is selected.

Otherwise it looks good.
dive2xs is offline   Reply With Quote
Old 30th January 2006, 18:37   #13
dive2xs
Junior Member
 
Join Date: Jul 2005
Posts: 14
Also got this warning:
LangString "BAD_PORT_NUM" is not set in language table of language English
dive2xs is offline   Reply With Quote
Old 30th January 2006, 20:10   #14
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Birmingham, England
Posts: 8,202
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:
code:
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

Need an installer? http://www.afrowsoft.co.uk
Afrow UK is offline   Reply With Quote
Old 30th January 2006, 21:19   #15
dive2xs
Junior Member
 
Join Date: Jul 2005
Posts: 14
Thanks
dive2xs is offline   Reply With Quote
Reply
Go Back   Winamp Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump