Announcement

Collapse
No announcement yet.

Section control using flags

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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

  • #2
    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.

    Comment


    • #3
      That's where the Edit button is for .
      "I'll quote you when you say something memorable."
      - Claudia Pelsmaeker

      Comment


      • #4
        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

        Comment


        • #5
          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

          Comment


          • #6
            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.

            Comment


            • #7
              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

              Comment


              • #8
                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.

                Comment


                • #9
                  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

                  Comment


                  • #10
                    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

                    Comment


                    • #11
                      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.

                      Comment


                      • #12
                        Enjoy:

                        NSIS FAQ | NSIS Home Page | Donate $
                        "I hear and I forget. I see and I remember. I do and I understand." -- Confucius

                        Comment


                        • #13
                          Thanks a lot kichik.

                          Comment


                          • #14
                            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!

                            Comment


                            • #15
                              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 
                              My new location

                              Comment

                              Working...
                              X
                              😀
                              🥰
                              🤢
                              😎
                              😡
                              👍
                              👎