Reference/Section: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
(Seperated the two examples)
Line 32: Line 32:
   MessageBox MB_OK "name of ${sec2_id}:$\n$0" # will correctly display 'name of 1: test2'
   MessageBox MB_OK "name of ${sec2_id}:$\n$0" # will correctly display 'name of 1: test2'
FunctionEnd
FunctionEnd
</highlight-nsis>
<highlight-nsis>
Function .onInit
Function .onInit
   SectionGetText ${sec2_id} $0
   SectionGetText ${sec2_id} $0

Revision as of 19:37, 13 June 2015

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