Archive: Section control using flags


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!


Re: Section control using flags
 

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.

That's where the Edit button is for :).


Have you tried settings the initial value for $R0 and $R1? Set it in .onInit.


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 :D
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.

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.


I don't understand, if you got it to work what's the problem?


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. ;)


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.


I think he has come up with that idea too, but didn't find the right words for it. What code should he use?


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. :)


Enjoy:

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


Thanks a lot kichik. :)


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!


I didn't see kichik's example but I'll give you my. I hope it is what you need.


name 'example'


>outfile 'example.exe'

>!include 'sections.nsh'

>page components
page instfiles

showinstdetails show

>var sec_var

section/o '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
>

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!


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 ;)


I missed one thing - remember ${sec2} in $R9 on init.


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! :) :)

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!


http://forums.winamp.com/showthread.php?t=341517

Stu