Archive: unchecked subsection as default


unchecked subsection as default
Hi there and hello

Is it possible to have an subsection unchecked as default

eg.

section
- [x] subsection 1
- [_] subsection 2

Additional:
Is it possible to change the [x] for subsection 2 depending on existing values (e.g feature was installed before (or not))

example:
on first installation subs2 is nailed, user deselected it - and on upgrade (or 2nd installation) subs2 is not nailed.

thx


sorry - from help

>> If the Switch /o is specified than the Section is unselected by default.

but my second question is still unanswered. is it possible?


I found a macro in a NSH

; Set one or more BITS in SECTION's flags.
!macro SetSectionFlag SECTION BITS
Push $R0
SectionGetFlags "${SECTION}" $R0
IntOp $R0 $R0 | "${BITS}"
SectionSetFlags "${SECTION}" $R0
Pop $R0
!macroend

; Clear one or more BITS in SECTION's flags.
!macro ClearSectionFlag SECTION BITS
Push $R0
Push $R1
SectionGetFlags "${SECTION}" $R0
IntOp $R1 "${BITS}" ~
IntOp $R0 $R0 & $R1
SectionSetFlags "${SECTION}" $R0
Pop $R1
Pop $R0
!macroend


Maybe

!insertmacro SetSectionFlag

but SECTION and BITS? how? pls tell me

can i include the text containing the macro like this without copying the macro itself to my nsi-script or is it included automatically?

!include "${NSISDIR}\include\sections.nsh"

Originally posted by Brummelchen sorry - from help

>> If the Switch /o is specified than the Section is unselected by default.
where did you get this?
4.6.1.2 Section

[/e] [section_name] [section index output]

Begins and opens a new section. If section_name is empty, omitted, or begins with a -, then it is a required section and the user will not see it, nor have the option of disabling it. If the section name is 'Uninstall', then it is a special Uninstall Section. If section index output is specified, the parameter will be !defined with the section index (that can be used for SectionSetText etc). If the section name begins with a !, the section will be displayed as bold. If /e is present, the sub sections of the section will be expanded by default.

NSIS Help Chapter 4 CVS from the last 3 days or before !

Section flags have to be changed if the concerning file was installed on a previos setup - normal it is unchecked due to a Web-Setup.


You don't need ClearSectionFlag, you can use UnselectSection from the same file. Just so you'd know next time, the flags (BITS) are listed on the top of Sections.nsh (SF_*), and SECTION is the section id as always.


@kichik

man ur great :)


!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE
Page custom find_xyz ; this is a normal function call

!insertmacro MUI_PAGE_COMPONENTS

...

Function find_xyz
IfFileExists $INSTDIR\xyz\xyz.exe 0 noabsfsec
absfsec:
MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2
"A previous version of '${MUI_PRODUCT} xyz' was found.
$\nWould you like to install the latest version?"
IDNO noabsfsec
SectionSetFlags ${SecInfo2} 1
noabsfsec:
FunctionEnd


BTW is this the correct syntax?

SectionSetFlags ${SecInfo2} 1 <-- "1" or do i have to use other flags? (0x01)

1 is the same as SF_SELECTED. There is absolutely no difference. Why would you use SectionSetFlags though? What's wrong with SelectSection?


Hmm... It's not the macro. SetSectionFlags 1 to select the section should be enough but if you choose to add other flags such as bold or read only it will remove them. You should use the SelectSection macro from Sections.nsh.


@kichik

SF_SELECTED is synonym for "0x01" ?

> What's wrong with SelectSection?

You mean that
!insertmacro SelectSection $1
may the easier way?

if that does set flag SF_SELECTED without changing other flags (bold aso.) that would help me.

This is my first time into deep nsis :)


${SF_SELECTED} is defined as 1 (or 0x01, same thing). It's the exact same thing, but SF_SELECTED's meaning is far more easier to understand than 1 ;)

Saving other flags is the exact reason to use the macro (or just its content).


> ${SF_SELECTED} is defined as 1

This works
IntOp $0 $0 | 1

this not
IntOp $0 $0 | ${SF_SELECTED}

I modified the routine:

;set SectionFlags to "found"
Push $0
SectionGetFlags ${SecInfo2} $0
IntOp $0 $0 | 1
SectionSetFlags ${SecInfo2} $0
Pop $0

I dont know how to work with
!insertmacro SelectSection $1

it causes errors while compiling.


You have to include Sections.nsh for SF_SELECTED and the macros to be defined.

You've used $1 in the macro instead of the section. It should look like this:

!insertmacro SelectSection ${SecInfo2}

What errors do you get? If it tells you the macro wasn't found then you should add "!include Sections.nsh" to your script.


@kichik

> add "!include Sections.nsh" to your script.

i forgot that - now it works perfectly. THX