Old 16th January 2003, 12:02   #1
cosmic66
Junior Member
 
Join Date: Jan 2003
Posts: 28
Section control using flags

Hi!

I'm new to NSIS and try to achieve the following:
I have two sections (s0 and s1) and their state (selection ON|OFF) should be dependend on each other:

When section s0 is deselcted, section s1 should be deselcted.
When section s1 is selected, section s0 should be deselcted.

I have followed the procedure described in previous postings and in
example "one-selection".

I have attached my NSI-file to this posting,
Setting the flags doesn't have an effect and s1 is not interactive in
the installer after its flag has been written.

I'm using NSIS v2.0b0.

Thanks for any hints on how to solve this problem!
Attached Files
File Type: nsi test.nsi (2.0 KB, 828 views)
cosmic66 is offline   Reply With Quote
Old 16th January 2003, 12:09   #2
cosmic66
Junior Member
 
Join Date: Jan 2003
Posts: 28
Re: Section control using flags

Quote:
Originally posted by cosmic66
[...]
When section s0 is deselcted, section s1 should be deselcted.
When section s1 is selected, section s0 should be deselcted.
[...]
[/B]
Sorry, there was a mistake,
the correction is:


When section s0 is deselcted, section s1 should be deselcted.
When section s1 is selected, section s0 should be selected.
cosmic66 is offline   Reply With Quote
Old 16th January 2003, 19:13   #3
virtlink
Major Dude
 
virtlink's Avatar
 
Join Date: Sep 2002
Location: At [4C69:6E6B]
Posts: 561
That's where the Edit button is for .

"I'll quote you when you say something memorable."
- Claudia Pelsmaeker
virtlink is offline   Reply With Quote
Old 17th January 2003, 11:26   #4
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
Have you tried settings the initial value for $R0 and $R1? Set it in .onInit.

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 17th January 2003, 12:04   #5
cosmic66
Junior Member
 
Join Date: Jan 2003
Posts: 28
Thumbs up

Quote:
Originally posted by kichik
Have you tried settings the initial value for $R0 and $R1? Set it in .onInit.
Thanks for your quick answer.
Setting the initial value for $R0 and $R1 doesn't make a difference.


But still I was able to solve the problem
I had a mistake in my flow (in which case to jump to which label) and I was using the wrong operation when setting the flag to being deselcted.

In case someone is interested, the working skript is attached to this posting.
Attached Files
File Type: nsi test.nsi (1.7 KB, 847 views)
cosmic66 is offline   Reply With Quote
Old 17th January 2003, 20:11   #6
japheth
Junior Member
 
Join Date: Mar 2002
Location: Canada
Posts: 10
Send a message via ICQ to japheth Send a message via AIM to japheth
I'm looking to do something similar, but not quite.

Here's what I need to do:

There are 4 components.

I need components 1 and 3 to be co-dependent upon one another. So, if a user selects component 1 and component 3 is selected, component 3 becomes unselected. Similarly, if a user selects component 3 and component 1 is selected, component 3 becomes unselected.

I've looked at one-section.nsi and at the script posted on this thread, and I sort of get it, however, it's not the kind of programming logic I'm used to coding in.

Any help is appreciated.
japheth is offline   Reply With Quote
Old 18th January 2003, 11:17   #7
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
I don't understand, if you got it to work what's the problem?

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 18th January 2003, 17:13   #8
japheth
Junior Member
 
Join Date: Mar 2002
Location: Canada
Posts: 10
Send a message via ICQ to japheth Send a message via AIM to japheth
Sorry, I guess I should of explained myself better.

I don't have it working at all. And actually, instead of co-dependent, I should of said mutually exclusive.

one-section.nsi is *almost* what I need. The only thing is, in one-section.nsi, at least one section is required. I need something similar to that, except that no section will be required, the user just can't have component 3 selected if component 1 is selected and visa-versa.


Hopefully that clears things up.
japheth is offline   Reply With Quote
Old 18th January 2003, 19:15   #9
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
OK, then lets think of a script logic for that.

What you need to do is initially select only one of them to make the initial state valid. Do this in .onInit. Remember what section you initially selected. Then in .onSelChange check to see if the section that wasn't remembered is selected. If it is, remember it and uncheck the one that was remembered earlier. That's all you need to do. It should cover all cases.

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 18th January 2003, 21:18   #10
virtlink
Major Dude
 
virtlink's Avatar
 
Join Date: Sep 2002
Location: At [4C69:6E6B]
Posts: 561
I think he has come up with that idea too, but didn't find the right words for it. What code should he use?

"I'll quote you when you say something memorable."
- Claudia Pelsmaeker
virtlink is offline   Reply With Quote
Old 19th January 2003, 07:29   #11
japheth
Junior Member
 
Join Date: Mar 2002
Location: Canada
Posts: 10
Send a message via ICQ to japheth Send a message via AIM to japheth
Yeah, virtlink hit the proverbial nail on the head.

I know the logic that's required, it's just that I'm pretty bad with NSIS's programming logic.

I hate being hand-held just as much as the next person, but I've been farting around with this for the past couple of days with no results.

If someone could come up with a small snippet of code, I'd be much appreciative.

Perhaps it could even be included in the examples as mutual-excluseive.nsi or something. I'm sure someone else will want to do something similar to this in the future.
japheth is offline   Reply With Quote
Old 19th January 2003, 15:52   #12
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
Enjoy:

http://nsis.sourceforge.net/archive/...instances=0,64

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 20th January 2003, 00:02   #13
japheth
Junior Member
 
Join Date: Mar 2002
Location: Canada
Posts: 10
Send a message via ICQ to japheth Send a message via AIM to japheth
Thanks a lot kichik.
japheth is offline   Reply With Quote
Old 25th October 2007, 10:00   #14
tkm2007
Junior Member
 
Join Date: Oct 2007
Posts: 3
Hello everyone!

I am trying to create an installer with 2 sections which cannot be both selected at once, exactly as japheth. I saw the example kichik posted, but I would like to ask how I can have the second section selected by default, and not the first one as shown in the example.

Thank you!
tkm2007 is offline   Reply With Quote
Old 25th October 2007, 10:13   #15
pospec
Senior Member
 
pospec's Avatar
 
Join Date: Jun 2007
Location: Otrokovice, Czech Republic
Posts: 308
I didn't see kichik's example but I'll give you my. I hope it is what you need.
PHP Code:
name 'example'

outfile 'example.exe'

!include 'sections.nsh'

page components
page instfiles

showinstdetails show

var sec_var

section 
/'first' sec_1
  detailprint 
'first section'
sectionend

section 
'second' sec_2
  detailprint 
'second section'
sectionend

function .onselchange
  
!insertmacro startradiobuttons $sec_var
    
!insertmacro radiobutton ${sec_1}
    !
insertmacro radiobutton ${sec_2}
  !
insertmacro endradiobuttons
functionend 
pospec is offline   Reply With Quote
Old 25th October 2007, 10:17   #16
tkm2007
Junior Member
 
Join Date: Oct 2007
Posts: 3
Thank you pospec for your quick reply. I have already found this way in the web, but it doesn't give me the option to have no section selected as kichik's example does. Thank you anyway!
tkm2007 is offline   Reply With Quote
Old 25th October 2007, 10:24   #17
pospec
Senior Member
 
pospec's Avatar
 
Join Date: Jun 2007
Location: Otrokovice, Czech Republic
Posts: 308
I see. If you like his example then you can modify it for your purposes. Just change IntOp $0 $0 & ${SECTION_OFF} with IntOp $0 $0 | ${SF_SELECTED} and vice versa in .onInit
pospec is offline   Reply With Quote
Old 25th October 2007, 10:31   #18
pospec
Senior Member
 
pospec's Avatar
 
Join Date: Jun 2007
Location: Otrokovice, Czech Republic
Posts: 308
I missed one thing - remember ${sec2} in $R9 on init.
pospec is offline   Reply With Quote
Old 25th October 2007, 10:32   #19
tkm2007
Junior Member
 
Join Date: Oct 2007
Posts: 3
Quote:
Originally posted by pospec
I see. If you like his example then you can modify it for your purposes. Just change IntOp $0 $0 & ${SECTION_OFF} with IntOp $0 $0 | ${SF_SELECTED} and vice versa in .onInit
Thank you very much pospec for your time! It workd!
tkm2007 is offline   Reply With Quote
Old 15th February 2012, 05:45   #20
sr164w
Junior Member
 
Join Date: Nov 2011
Posts: 10
I need same kind of mutual exclusion wrt " Main " section. I am using Main section of nsi file only to copy few files. i need to achieve to copy few files when some variable set to true.
if i put only File command to copy files when variable set to flase also installer is trying to copy those files and giving me error. If i use /nonfatal with File command then installer gives warning.
what exactly i want achieve is installer should only try to copy if variable set to true. if variable is false then there File command should not get executed.
Any help would be highly appreciated!
sr164w is offline   Reply With Quote
Old 15th February 2012, 11:22   #21
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
http://forums.winamp.com/showthread.php?t=341517

Stu
Afrow UK is offline   Reply With Quote
Old 23rd May 2021, 12:03   #22
extremecarver
Junior Member
 
Join Date: Apr 2013
Posts: 37
I have the same problem as above,
pospecs solution doesn't give me the option to have no section selected.

I do not understand the explication about on init. I do not have
any code like the following which I could exchange.
IntOp $0 $0 & ${SECTION_OFF} with IntOp $0 $0 | ${SF_SELECTED}.

I only have
SectionSetFlags 1 $sec1_enabled
SectionSetFlags 2 $sec2_enabled
SectionSetFlags 3 $sec3_enabled
SectionSetFlags 4 $sec4_enabled


I had another example that worked - but only for subsequent sections, so it works for sec2 and sec3 mutually exclusive, but not sec2 and sec4 mutually exclusive:

Function .onSelChange
${IfThen} $0 = -1 ${|} Return ${|} ; I don't care about InstType changes
${If} $0 = ${sec2}
${OrIf} $0 = ${sec4}
Return ; I don't care about other sections
${EndIf}

!macro SelectOnlyMe sid
${IfThen} $0 <> ${sid} ${|} v ${sid} ${|}
!macroend

!insertmacro SelectOnlyMe ${sec2}
!insertmacro SelectOnlyMe ${sec4}
FunctionEnd


This code will make the selection mutually exclusive, but sometimes work strangely with sec3 combination.
extremecarver is offline   Reply With Quote
Old 23rd May 2021, 17:03   #23
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,418
Don't call SectionSetFlags directly like that. Post more code, it is hard to understand what is going on.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 26th May 2021, 14:43   #24
extremecarver
Junior Member
 
Join Date: Apr 2013
Posts: 37
okay - I reworked the whole thing. However no matter if I call SectionSETFlags directly or not - the radio buttons are bugged. They only work correctly if clicking by hand. If I preselect an option - and it is different to sec1 - then I can first select 2 sections - and only the next click will unselect the other options.

Each section if installed will put a String into the HKLM windows registry, then on next install I check for that string to offer the same install options as the user chose the last time. This works fine if sec1 was installed, but if it was sec2 or sec3 then clicking on sec2/sec3 will activate two sections - even though radio buttons are supposed to only allow one out of the three to be selected.

Section /o "Install 1" sec1
SectionIn 1
WriteRegDWORD HKLM "SOFTWARE\Garmin\MapSource\Families\${REG_KEY}" "SECTION_1" $sec1_enabled
SectionEnd

Section /o "Install 2" sec2
SectionIn 2
WriteRegDWORD HKLM "SOFTWARE\Garmin\MapSource\Families\${REG_KEY}" "SECTION_2" $sec2_enabled
SectionEnd

...

Function .onInit
ReadRegStr $1 HKLM "SOFTWARE\Garmin\MapSource\Families\${REG_KEY}" "SECTION_1"
StrCmp $1 "0" 0 Continue11
!insertmacro UnselectSection ${sec1}
Goto Continue111
Continue11:
!insertmacro SelectSection ${sec1}
Continue111:

ReadRegStr $2 HKLM "SOFTWARE\Garmin\MapSource\Families\${REG_KEY}" "SECTION_2"
StrCmp $2 "0" 0 Continue12
!insertmacro UnselectSection ${sec2}
Goto Continue121
Continue12:
!insertmacro SelectSection ${sec2}
Continue121:

ReadRegStr $3 HKLM "SOFTWARE\Garmin\MapSource\Families\${REG_KEY}" "SECTION_3"
StrCmp $3 "0" 0 Continue13
!insertmacro UnselectSection ${sec3}
Goto Continue131
Continue13:
!insertmacro SelectSection ${sec3}
Continue131:

ReadRegStr $4 HKLM "SOFTWARE\Garmin\MapSource\Families\${REG_KEY}" "SECTION_4"
StrCmp $4 "0" 0 Continue14
!insertmacro UnselectSection ${sec4}
Goto Continue141
Continue14:
!insertmacro SelectSection ${sec4}
Continue141:

ReadRegStr $5 HKLM "SOFTWARE\Garmin\MapSource\Families\${REG_KEY}" "SECTION_5"
StrCmp $5 "0" 0 Continue15
!insertmacro UnselectSection ${sec5}
Goto Continue151
Continue15:
!insertmacro SelectSection ${sec5}
Continue151:

StrCpy $6 "$1$2$3$4$5"
StrCmp $6 "00000" 0 Continue20
!insertmacro SelectSection ${sec2}
continue20:
FunctionEnd

; Create a mutually exclusive group of sec1, sec2 and sec3. Only one of them can be and has to be activated.
Function .onSelChange
!insertmacro StartRadioButtons $1
!insertmacro RadioButton ${sec1}
!insertmacro RadioButton ${sec2}
!insertmacro RadioButton ${sec3}
!insertmacro EndRadioButtons
FunctionEnd
extremecarver is offline   Reply With Quote
Old 26th May 2021, 15:00   #25
extremecarver
Junior Member
 
Join Date: Apr 2013
Posts: 37
And If I use SectionGroup for sec1 sec2 sec3 it goes complete havoc. Depending on what way I achieved the section settings it will be different. In the last example given as soon as I add it to a group - I cannot unselect any section out of that group anymore.
Meaning
SectionGroup /e "group"
Section 1-3
SectionGroupEND


Forgot above - to set those flags I use
SectionGetFlags 1 $sec1_enabled
SectionGetFlags 2 $sec2_enabled
SectionGetFlags 3 $sec3_enabled
SectionGetFlags 4 $sec4_enabled
SectionGetFlags 5 $sec5_enabled

WriteRegDWORD HKLM "SOFTWARE\Garmin\MapSource\Families\${REG_KEY}" "SECTION_1" $sec1_enabled
WriteRegDWORD HKLM "SOFTWARE\Garmin\MapSource\Families\${REG_KEY}" "SECTION_2" $sec2_enabled
WriteRegDWORD HKLM "SOFTWARE\Garmin\MapSource\Families\${REG_KEY}" "SECTION_3" $sec3_enabled
WriteRegDWORD HKLM "SOFTWARE\Garmin\MapSource\Families\${REG_KEY}" "SECTION_4" $sec4_enabled
WriteRegDWORD HKLM "SOFTWARE\Garmin\MapSource\Families\${REG_KEY}" "SECTION_5" $sec5_enabled
extremecarver is offline   Reply With Quote
Old 26th May 2021, 15:03   #26
extremecarver
Junior Member
 
Join Date: Apr 2013
Posts: 37
oh sorry - my message before is missing- are longer messages not allowed, but shorter are?

My on.init is like this

Quote:
Function .onInit
ReadRegStr $1 HKLM "SOFTWARE\Garmin\MapSource\Families\${REG_KEY}" "SECTION_1"
StrCmp $1 "0" 0 Continue11
!insertmacro UnselectSection ${sec1}
Goto Continue111
Continue11:
!insertmacro SelectSection ${sec1}
Continue111:

ReadRegStr $2 HKLM "SOFTWARE\Garmin\MapSource\Families\${REG_KEY}" "SECTION_2"
StrCmp $2 "0" 0 Continue12
!insertmacro UnselectSection ${sec2}
Goto Continue121
Continue12:
!insertmacro SelectSection ${sec2}
Continue121:

ReadRegStr $3 HKLM "SOFTWARE\Garmin\MapSource\Families\${REG_KEY}" "SECTION_3"
StrCmp $3 "0" 0 Continue13
!insertmacro UnselectSection ${sec3}
Goto Continue131
Continue13:
!insertmacro SelectSection ${sec3}
Continue131:

ReadRegStr $4 HKLM "SOFTWARE\Garmin\MapSource\Families\${REG_KEY}" "SECTION_4"
StrCmp $4 "0" 0 Continue14
!insertmacro UnselectSection ${sec4}
Goto Continue141
Continue14:
!insertmacro SelectSection ${sec4}
Continue141:

ReadRegStr $5 HKLM "SOFTWARE\Garmin\MapSource\Families\${REG_KEY}" "SECTION_5"
StrCmp $5 "0" 0 Continue15
!insertmacro UnselectSection ${sec5}
Goto Continue151
Continue15:
!insertmacro SelectSection ${sec5}
Continue151:

StrCpy $6 "$1$2$3$4$5"
StrCmp $6 "00000" 0 Continue20
!insertmacro SelectSection ${sec2}
continue20:
FunctionEnd

; Create a mutually exclusive group of sec1, sec2 and sec3. Only one of them can be and has to be activated.
Function .onSelChange
!insertmacro StartRadioButtons $1
!insertmacro RadioButton ${sec1}
!insertmacro RadioButton ${sec2}
!insertmacro RadioButton ${sec3}
!insertmacro EndRadioButtons
FunctionEnd
extremecarver is offline   Reply With Quote
Old 26th May 2021, 15:44   #27
extremecarver
Junior Member
 
Join Date: Apr 2013
Posts: 37
The Following is perfect - but really user unfriendly. Before you can tick another one - you need to untick one (well you can tick 2 or 1 if 3 is ticked - because the if comes later). So I guess the radiobutton macro is simply very buggy...


Function .onSelChange
${If} ${SectionIsSelected} ${sec1}
!insertmacro UnSelectSection ${sec2}
!insertmacro UnSelectSection ${sec3}
${EndIf}
${If} ${SectionIsSelected} ${sec2}
!insertmacro UnSelectSection ${sec1}
!insertmacro UnSelectSection ${sec3}
${EndIf}
${If} ${SectionIsSelected} ${sec3}
!insertmacro UnSelectSection ${sec2}
!insertmacro UnSelectSection ${sec1}
${EndIf}
FunctionEnd
extremecarver is offline   Reply With Quote
Old 26th May 2021, 16:16   #28
NJK
FRYSK BLOED TSJOCH OP- FRISIAN
 
NJK's Avatar
 
Join Date: Sep 2003
Location: a real Frisian hometown
Posts: 15,621
Quote:
Originally Posted by extremecarver View Post
oh sorry - my message before is missing- are longer messages not allowed, but shorter are?
Nope , with much that is not clear, your posts need moderation before the can be seen.
You post a lot of code and the system this board is using can't detect if that is spam or not.

Each Thursday a new show on Celtica Radio with Darkwave music.

WINAMPSHOUTCAST
NJK is offline   Reply With Quote
Old 27th May 2021, 11:20   #29
extremecarver
Junior Member
 
Join Date: Apr 2013
Posts: 37
What is the way to change the section without breaking radiobuttons?
${SectionIsSelected} ${sec3}
breaks radiobutton

was also breaking radiobuttons..
${IfThen} $0 <> ${sid} ${|} v ${sid} ${|}


Is not doing anything at all for me:
Function .onInit
StrCpy $1 ${sec2}
FunctionEnd

Function .onSelChange
!insertmacro StartRadioButtons $1
!insertmacro RadioButton ${sec1}
!insertmacro RadioButton ${sec2}
!insertmacro RadioButton ${sec3}
!insertmacro EndRadioButtons
FunctionEnd
extremecarver is offline   Reply With Quote
Old 27th May 2021, 11:30   #30
extremecarver
Junior Member
 
Join Date: Apr 2013
Posts: 37
SectionSetFlags ${sec2} 1
Also causes radio button Problems.

What code can I use that is exactly the same as clicking a section. Cause all the code that I find to default preactivate a section - clashes with radiobutton. The radiobutton does not know the box is activated and acts like it is not activated.
extremecarver is offline   Reply With Quote
Old 28th May 2021, 07:37   #31
extremecarver
Junior Member
 
Join Date: Apr 2013
Posts: 37
After searching for a working solution for ages - I am back to this one. Radiobuttons macro Is so inherently bugged that I will not use it anymore.
This works as expected - except you can deselect all options - so I changed the rest of my installer for that ( I will think how I can make sure that if no section is installed, it calls the uninstaller if it exists). Radiobuttons only works if nothing is selected beforehand.

code:
Function .onSelChange
${IfThen} $0 = -1 ${|} Return ${|} ; I don't care about InstType changes
${If} $0 < ${sec1}
${OrIf} $0 > ${sec3}
Return ; I don't care about other sections
${EndIf}

!macro SelectOnlyMe sid
${IfThen} $0 <> ${sid} ${|} !insertmacro UnselectSection ${sid} ${|}
!macroend

!insertmacro SelectOnlyMe ${sec1}
!insertmacro SelectOnlyMe ${sec2}
!insertmacro SelectOnlyMe ${sec3}
FunctionEnd



I do not think this can be adapted well to more than 3 sections. But for 3 sections this works perfectly.
extremecarver is offline   Reply With Quote
Old 28th May 2021, 19:59   #32
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,418
This SelectOnlyMe code is some random code you found on Stackoverflow? I'm pretty sure I wrote it and it is possible the person wanted to be able to unselect the radio.

Try NSIS\Examples\one-section.nsi instead...

Or if you must:

PHP Code:
!include Sections.nsh
!include LogicLib.nsh
page components
page instfiles

Section 1 sec1
SectionEnd 
Section 2 sec2
SectionEnd 
Section 3 sec3
SectionEnd 
Section 4 sec4
SectionEnd 


Function .onSelChange
!macro ActAsRadio first last
${If} $>= ${first}
${
AndIf} $<= ${last}
    ${ForEach} $
${first} ${last} + 1
        
${If} $<> $1
            
!insertmacro UnselectSection $1
        
${Else}
            !
insertmacro SelectSection $1
        
${EndIf}
    ${
Next}
${EndIf}
!
macroend

!insertmacro ActAsRadio ${sec1} ${sec4}
FunctionEnd

Function .onInit
StrCpy 
$${sec2} ; Default radio for this group
Call 
.onSelChange Enforce it
FunctionEnd 

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 28th May 2021, 22:04   #33
extremecarver
Junior Member
 
Join Date: Apr 2013
Posts: 37
NSIS\Examples\one-section.nsi is the one where it went havoc if I preselected an option. Also the radio buttons do not seem to work well with a single section group and many other problems.

Thanks for your code example. I think yes I found that code on stack overflow. I now wrote about 500 lines of nsis code to work around the possibility that someone unselects all of option 1-3... Still tearing my hair out as the logic then becomes very complicated...
extremecarver is offline   Reply With Quote
Old 6th September 2021, 20:30   #34
extremecarver
Junior Member
 
Join Date: Apr 2013
Posts: 37
I'm having another problem with the predefined selections. The section size is changing depending on which section is selected. That works well as soon as the user actively clicked on a section. However if the section comes preselected due to insertmacro SelectSection it is not enforced.

code:
Function .onInit
StrCpy $1 ""
ReadRegStr $1 HKLM "SOFTWARE\Garmin\MapSource\Families\${REG_KEY}"
"SECTION_1"
StrCmp $1 "1" 0 Continue11
;MessageBox MB_OK "$1 -SelectSection ${sec1}"
!insertmacro SelectSection ${sec1}
Goto Continue111
Continue11:
Continue111:

StrCpy $2 ""
ReadRegStr $2 HKLM "SOFTWARE\Garmin\MapSource\Families\${REG_KEY}"
"SECTION_2"
StrCmp $2 "1" 0 Continue12
!insertmacro SelectSection ${sec2}
Goto Continue121
Continue12:
Continue121:

.....
..... and some more sections

Call .onSelChange



code:

${If} ${SectionIsSelected} ${sec2}
SectionSetSize ${sec4} 10
${Else}
SectionSetSize ${sec4} 10000
${EndIf}

${If} ${SectionIsSelected} ${sec3}
SectionSetSize ${sec5} 10
${Else}
SectionSetSize ${sec5} 10000
${EndIf}

${If} ${SectionIsSelected} ${sec4}
${AndIf} ${SectionIsSelected} ${sec2}
SectionSetSize ${sec4} 10
${EndIf}

..... some more conditions



So before I actively change section 1-3 (only one can be selected or none which works) - the SectionSetSize will not work correctly or at all.

In effect the idea is if section 2 is selected - then sec4 is size 10 (because it's the same files mainly getting installed. If not then it is 10000. If sec3 is selected - then sec5 size is 10, if not then 10000

But this code only works after actually selecting one of sec1 to sec3. Not with the preselection via !insertmacro SelectSection
extremecarver is offline   Reply With Quote
Old 6th September 2021, 20:39   #35
extremecarver
Junior Member
 
Join Date: Apr 2013
Posts: 37
well - maybe I should have added the code in an attachement, instead inline.
So I will try again.

The following section setsize only works if sec1 sec2 or sec3 has been actively selected. Not if it comes preselected via on.init..

Not sure what I'm doing wrong here or if there is a bug...

I attached the relevant code...
Attached Files
File Type: txt ful_text.txt (3.4 KB, 162 views)
extremecarver is offline   Reply With Quote
Old 7th September 2021, 00:32   #36
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,418
Ideally example code should be

- Self contained
- As minimal as possible
- Compile without changes

and your attached code is none of those things.

Please take my example code above and modify it until it exhibits the problem you are talking about.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast 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