Reference/Section
From NSIS Wiki
Jump to navigationJump to search
Section
From the Glossary (v2.38 on 8/29/08) | |
---|---|
Section: | A block of commands "executed in order by the resulting installer." "If [Attribute] ComponentText is set, the user will have the option of disabling/enabling each visible section. If a section's name is 'Uninstall' or is prefixed with 'un.', it's an uninstaller section." |
[/o] [([!]|[-])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 hidden section and the user will not have the option of disabling it. If the section name is 'Uninstall' or is prefixed with 'un.', then it is a an uninstaller 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 the /o switch is specified, the section will be unselected by default.
Section "-hidden section" SectionEnd Section # hidden section SectionEnd Section "!bold section" SectionEnd Section /o "optional" SectionEnd Section "install something" SEC_IDX SectionEnd
To access the section index, curly brackets must be used and the code must be located below the section in the script.
Section test1 sec1_id SectionEnd Section test2 sec2_id SectionEnd Function .onInit SectionGetText ${sec2_id} $0 MessageBox MB_OK "name of ${sec2_id}:$\n$0" # will correctly display 'name of 1: test2' FunctionEnd
Function .onInit SectionGetText ${sec2_id} $0 MessageBox MB_OK "name of ${sec2_id}:$\n$0" # will incorrectly display 'name of ${sec2_id}: test1' # plus a warning stating: # unknown variable/constant "{sec2_id}" detected, ignoring FunctionEnd Section test1 sec1_id SectionEnd Section test2 sec2_id SectionEnd