Reference/Section: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
(Add glossary definition)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
=Section=
=Section=
{| style="border-collapse: collapse;" class="wikitable"
|- style="border: 1px solid #a2a9b1"
|
! '''From the [[Glossary]]''' (v2.38 on 8/29/08)
|-
| style="border: 1px solid #a2a9b1" | '''Section:'''
| style="border: 1px solid #a2a9b1" | 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."
|}
[[Category:Help]]


  [/o] [([!]|[-])section_name] [section_index_output]
  [/o] [([!]|[-])section_name] [section_index_output]
Line 32: Line 45:
   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

Latest revision as of 23:45, 30 December 2020

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