Archive: How to hide a section programmatically


How to hide a section programmatically
I am aware of how to hide a section at section declaration by using empty section name or a "." in front of the section name. But can I hide a section in a programmatic way?

I have tried to use SF_RO flag, but that only turns the section into read-only mode:
!insertmacro SetSectionFlag ${SEC_IDX} ${SF_RO}

Your help is greatly appreciated.


Best thing to do is put a - in front of the name to hide the section, and remove it to unhide the section again.

Good idea for a set of functions actually. Perhaps I'll write two soon (after I put some food in the oven!)

Edit: Ok that doesn't seem to work at all!
You'll just have to put your names in defines so that you can re-apply them when you want to unhide the section.

-Stu


SectionSetText ${SEC_2} ""

works for me.

So that is how to *hide* the section...
... but how do you ensure that section does not get executed during installation?

According to the documentation, paragraph 4.6.1.2

If section_name is empty, omitted, or begins with a -, then it is a hidden section and the user will not have the option of disabling it.
My experiments imply that this applies to sections whose names are altered programatically to the empty string "".

Is there a way to hide a section (depending on install type) and make sure that it doesn't get executed?

yes there is.

...
SectionSetText ${sec01} ""
...
Section "blabla" sec01
SectionGetText $0 ${sec01}
StrCmp $0 "" sec_end
...
sec_end:
SectionEnd
...

Or simply unselect them programmatically with SectionSetFlags or the UnselectSection macro from Sections.nsh.