WINAMP.COM | Forums : Powered by vBulletin version 2.3.9 WINAMP.COM | Forums > Developer Center > NSIS Discussion > Section with options, howto?
  Last Thread   Next Thread
Author
Thread Post New Thread    Post A Reply
gurzixo
Junior Member

Registered: Jan 2008
From:

Section with options, howto?

Dear All,

While this is not my first nsis script, I think I have not grabbed the full NSIS spirit yet..., and I am ckoking on this seemingly very simple problem:

My install script needs an user-selectable section, with an user-selectable option. By default, this option is checked or not depending on the value of a registry key. Obviously, if the section is not selected, the option should be grayed out. The action of this section (if selected) is something like:
"execwait myprog.exe -myoption" or "execwait myprog" depending if the option is checked or not.

I tried using sections inside sections (does not work), then SectionGroups. But I have not been able to to get a consistent checking logic.

Any help would be *really* welcome!

Michel

Quick Link | Report this post to a moderator | IP: Logged

gurzixo is offline Old Post 01-17-2008 02:53 PM
Click Here to See the Profile for gurzixo Click here to Send gurzixo a Private Message Find more posts by gurzixo Add gurzixo to your buddy list Edit/Delete Message Reply w/Quote
Red Wine
Forum King

Registered: Mar 2006
From: Ath. GR

Something like this I guess,

code:
!include "Sections.nsh" !include "logiclib.nsh" Section "MyProg" sec1 # SectionEnd Section /o "MyOption" sec2 # SectionEnd Function .onSelChange SectionGetFlags ${sec1} $R0 IntOp $R0 $R0 & ${SF_SELECTED} ${If} $R0 == ${SF_SELECTED} !insertmacro ClearSectionFlag ${sec2} ${SF_RO} ${ElseIf} $R0 != ${SF_SELECTED} !insertmacro UnSelectSection ${sec2} !insertmacro SetSectionFlag ${sec2} ${SF_RO} ${EndIf} FunctionEnd

__________________
Quick AVI Creator - Quick and easy convert from DVD/MPEG/AVI/MKV to AVI/MP4/MKV
Quick AVI Creator entirely edited with NSIS and entirely upgraded to Unicode NSIS

Quick Link | Report this post to a moderator | IP: Logged

Red Wine is offline Old Post 01-17-2008 03:29 PM
Click Here to See the Profile for Red Wine Click here to Send Red Wine a Private Message Find more posts by Red Wine Add Red Wine to your buddy list Edit/Delete Message Reply w/Quote
gurzixo
Junior Member

Registered: Jan 2008
From:

Thanks a lot, Red Wine for your fast++ answer! At least I have now a working solution.

But could it be possible to have "MyOption" indented, like when using SectionGroup? This makes sense, as MyOption is a MyProg option, not an install option.

Again thanks,

Michel

Quick Link | Report this post to a moderator | IP: Logged

gurzixo is offline Old Post 01-17-2008 03:44 PM
Click Here to See the Profile for gurzixo Click here to Send gurzixo a Private Message Find more posts by gurzixo Add gurzixo to your buddy list Edit/Delete Message Reply w/Quote
Red Wine
Forum King

Registered: Mar 2006
From: Ath. GR

code:
SectionGroup /e "MyProg" Section "" sec1 # SectionEnd Section /o "MyOption" sec2 # SectionEnd SectionGroupEnd

__________________
Quick AVI Creator - Quick and easy convert from DVD/MPEG/AVI/MKV to AVI/MP4/MKV
Quick AVI Creator entirely edited with NSIS and entirely upgraded to Unicode NSIS

Quick Link | Report this post to a moderator | IP: Logged

Red Wine is offline Old Post 01-17-2008 04:04 PM
Click Here to See the Profile for Red Wine Click here to Send Red Wine a Private Message Find more posts by Red Wine Add Red Wine to your buddy list Edit/Delete Message Reply w/Quote
gurzixo
Junior Member

Registered: Jan 2008
From:

Red Wine, You rock!

As this could be of great use for the next newbie, I have created a new wiki page here: URL submitted by user.

Again thanks,

Michel

Quick Link | Report this post to a moderator | IP: Logged

gurzixo is offline Old Post 01-17-2008 05:57 PM
Click Here to See the Profile for gurzixo Click here to Send gurzixo a Private Message Find more posts by gurzixo Add gurzixo to your buddy list Edit/Delete Message Reply w/Quote
Red Wine
Forum King

Registered: Mar 2006
From: Ath. GR

You're welcome

Url submitted by the user gurzixo

__________________
Quick AVI Creator - Quick and easy convert from DVD/MPEG/AVI/MKV to AVI/MP4/MKV
Quick AVI Creator entirely edited with NSIS and entirely upgraded to Unicode NSIS

Quick Link | Report this post to a moderator | IP: Logged

Red Wine is offline Old Post 01-17-2008 07:01 PM
Click Here to See the Profile for Red Wine Click here to Send Red Wine a Private Message Find more posts by Red Wine Add Red Wine to your buddy list Edit/Delete Message Reply w/Quote
vlad-mal
Junior Member

Registered: Mar 2008
From:

quote:
Originally posted by Red Wine
Something like this I guess,
code:
!include "Sections.nsh" !include "logiclib.nsh" Section "MyProg" sec1 # SectionEnd Section /o "MyOption" sec2 # SectionEnd Function .onSelChange SectionGetFlags ${sec1} $R0 IntOp $R0 $R0 & ${SF_SELECTED} ${If} $R0 == ${SF_SELECTED} !insertmacro ClearSectionFlag ${sec2} ${SF_RO} ${ElseIf} $R0 != ${SF_SELECTED} !insertmacro UnSelectSection ${sec2} !insertmacro SetSectionFlag ${sec2} ${SF_RO} ${EndIf} FunctionEnd



That is interesting solution.
If there is a lot similar "slaved" sections, then code will be like this:

code:
!Include "MUI.nsh" !include "Sections.nsh" !include "logiclib.nsh" !insertmacro MUI_PAGE_COMPONENTS !insertmacro MUI_LANGUAGE "English" Name "Section with options" OutFile "test.exe" SectionGroup /e "MyProg" Section "Common" common SectionEnd Section /o "Option1" opt1 SectionEnd Section /o "Option2" opt2 SectionEnd Section /o "Option3" opt3 SectionEnd ;... ;...etc. ;... Section /o "OptionN" optN SectionEnd SectionGroupEnd Function .onSelChange SectionGetFlags ${common} $R0 IntOp $R0 $R0 & ${SF_SELECTED} ${If} $R0 == ${SF_SELECTED} !insertmacro ClearSectionFlag ${opt1} ${SF_RO} !insertmacro ClearSectionFlag ${opt2} ${SF_RO} !insertmacro ClearSectionFlag ${opt3} ${SF_RO} ;... ;...etc ;... !insertmacro ClearSectionFlag ${optN} ${SF_RO} ${ElseIf} $R0 != ${SF_SELECTED} !insertmacro UnSelectSection ${opt1} !insertmacro SetSectionFlag ${opt1} ${SF_RO} !insertmacro UnSelectSection ${opt1} !insertmacro SetSectionFlag ${opt2} ${SF_RO} !insertmacro UnSelectSection ${opt3} !insertmacro SetSectionFlag ${opt3} ${SF_RO} ;... ;...etc ;... !insertmacro UnSelectSection ${optN} !insertmacro SetSectionFlag ${optN} ${SF_RO} ${EndIf} FunctionEnd



A question: how to iterate across all sections from "opt1" to "optN" to avoid "Copy/Paste" in code?

Thanks.


/* Sorry for my poor English. */

Quick Link | Report this post to a moderator | IP: Logged

vlad-mal is offline Old Post 03-05-2008 12:59 PM
Click Here to See the Profile for vlad-mal Click here to Send vlad-mal a Private Message Click Here to Email vlad-mal Find more posts by vlad-mal Add vlad-mal to your buddy list Edit/Delete Message Reply w/Quote
vlad-mal
Junior Member

Registered: Mar 2008
From:

Solution:
As sinse section indexes is sequential, it possible simple iterate them from first section ("Common") till <Section Group End> flag is occured:

code:
Function ReCheckSection Var /Global fNextSection Var /Global IsSelected Pop $fNextSection SectionGetFlags $fNextSection $IsSelected IntOp $IsSelected $IsSelected & ${SF_SELECTED} IntOp $fNextSection $fNextSection + 1 ${DoUntil} ${SectionIsSectionGroupEnd} $fNextSection ${If} $IsSelected == ${SF_SELECTED} !insertmacro ClearSectionFlag $fNextSection ${SF_RO} ${ElseIf} $R0 != ${SF_SELECTED} !insertmacro UnSelectSection $fNextSection !insertmacro SetSectionFlag $fNextSection ${SF_RO} ${EndIf} IntOp $fNextSection $fNextSection + 1 ${LoopUntil} ${SectionIsSectionGroupEnd} $fNextSection FunctionEnd Function .onSelChange ; First section: Push ${common} Call ReCheckSection FunctionEnd



Thanks a lot.

Quick Link | Report this post to a moderator | IP: Logged

vlad-mal is offline Old Post 03-05-2008 03:00 PM
Click Here to See the Profile for vlad-mal Click here to Send vlad-mal a Private Message Click Here to Email vlad-mal Find more posts by vlad-mal Add vlad-mal to your buddy list Edit/Delete Message Reply w/Quote
vlad-mal
Junior Member

Registered: Mar 2008
From:

Just in case, full source code:

code:
!Include "MUI.nsh" !include "Sections.nsh" !include "logiclib.nsh" !insertmacro MUI_PAGE_COMPONENTS !insertmacro MUI_LANGUAGE "English" Name "Section with options" OutFile "test.exe" SectionGroup /e "MyProg" Section "Common" common SectionEnd Section /o "Option1" opt1 SectionEnd Section /o "Option2" opt2 SectionEnd Section /o "Option3" opt3 SectionEnd ;... ;...etc. ;... Section /o "OptionN" optN SectionEnd SectionGroupEnd Function ReCheckSection Var /Global fNextSection Var /Global IsSelected Pop $fNextSection SectionGetFlags $fNextSection $IsSelected IntOp $IsSelected $IsSelected & ${SF_SELECTED} IntOp $fNextSection $fNextSection + 1 ${DoUntil} ${SectionIsSectionGroupEnd} $fNextSection ${If} $IsSelected == ${SF_SELECTED} !insertmacro ClearSectionFlag $fNextSection ${SF_RO} ${ElseIf} $R0 != ${SF_SELECTED} !insertmacro UnSelectSection $fNextSection !insertmacro SetSectionFlag $fNextSection ${SF_RO} ${EndIf} IntOp $fNextSection $fNextSection + 1 ${LoopUntil} ${SectionIsSectionGroupEnd} $fNextSection FunctionEnd Function .onSelChange Push ${common} Call ReCheckSection FunctionEnd

Quick Link | Report this post to a moderator | IP: Logged

vlad-mal is offline Old Post 03-05-2008 03:06 PM
Click Here to See the Profile for vlad-mal Click here to Send vlad-mal a Private Message Click Here to Email vlad-mal Find more posts by vlad-mal Add vlad-mal to your buddy list Edit/Delete Message Reply w/Quote
All times are GMT. The time now is 09:38 AM. Post New Thread    Post A Reply
  Last Thread   Next Thread
WINAMP.COM | Forums : Powered by vBulletin version 2.3.9 WINAMP.COM | Forums > Developer Center > NSIS Discussion > Section with options, howto?
Show Printable Version
 | 
Email this Page
 | 
Subscribe to this Thread

Forum Jump:
 

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is off
vB code is ON
Smilies are ON
[IMG] code is ON