| 1 |
\H{sections} Sections |
| 2 |
|
| 3 |
Each NSIS installer contains one or more sections. Each of these sections are created, modified, and ended with the following commands. |
| 4 |
|
| 5 |
\b Each section contains zero or more instructions. |
| 6 |
|
| 7 |
\b Sections are executed in order by the resulting installer, and if a component page is used, the user will have the option of disabling/enabling each visible section. |
| 8 |
|
| 9 |
\b If a section's name is 'Uninstall' or is prefixed with 'un.', it's an uninstaller section. |
| 10 |
|
| 11 |
\S1{ssectioncommands} Section Commands |
| 12 |
|
| 13 |
\S2{saddsize} AddSize |
| 14 |
|
| 15 |
\c size_kb |
| 16 |
|
| 17 |
Tells the installer that the current section needs an additional "size_kb" kilobytes of disk space. Only valid within a section (will have no effect outside of a section or in a function). |
| 18 |
|
| 19 |
\c Section |
| 20 |
\c AddSize 500 |
| 21 |
\c SectionEnd |
| 22 |
|
| 23 |
\S2{ssection} Section |
| 24 |
|
| 25 |
\c [/o] [([!]|[-])section_name] [section_index_output] |
| 26 |
|
| 27 |
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 \e{section_index_output} is specified, the parameter will be \R{define}{!defined} with the section index (can be used with \R{sectionsettext}{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. |
| 28 |
|
| 29 |
\c Section "-hidden section" |
| 30 |
\c SectionEnd |
| 31 |
\c |
| 32 |
\c Section # hidden section |
| 33 |
\c SectionEnd |
| 34 |
\c |
| 35 |
\c Section "!bold section" |
| 36 |
\c SectionEnd |
| 37 |
\c |
| 38 |
\c Section /o "optional" |
| 39 |
\c SectionEnd |
| 40 |
\c |
| 41 |
\c Section "install something" SEC_IDX |
| 42 |
\c SectionEnd |
| 43 |
|
| 44 |
To access the section index, curly brackets must be used and the code must be located below the section in the script. |
| 45 |
|
| 46 |
\c Section test1 sec1_id |
| 47 |
\c SectionEnd |
| 48 |
\c |
| 49 |
\c Section test2 sec2_id |
| 50 |
\c SectionEnd |
| 51 |
\c |
| 52 |
\c Function .onInit |
| 53 |
\c SectionGetText ${sec2_id} $0 |
| 54 |
\c MessageBox MB_OK "name of ${sec2_id}:$\n$0" # will correctly display 'name of 1: test2' |
| 55 |
\c FunctionEnd |
| 56 |
|
| 57 |
\c Function .onInit |
| 58 |
\c SectionGetText ${sec2_id} $0 |
| 59 |
\c MessageBox MB_OK "name of ${sec2_id}:$\n$0" # will incorrectly display 'name of ${sec2_id}: test1' |
| 60 |
\c # plus a warning stating: |
| 61 |
\c # unknown variable/constant "{sec2_id}" detected, ignoring |
| 62 |
\c FunctionEnd |
| 63 |
\c |
| 64 |
\c Section test1 sec1_id |
| 65 |
\c SectionEnd |
| 66 |
\c |
| 67 |
\c Section test2 sec2_id |
| 68 |
\c SectionEnd |
| 69 |
|
| 70 |
\S2{ssectionend} SectionEnd |
| 71 |
|
| 72 |
This command closes the current open section. |
| 73 |
|
| 74 |
\S2{ssectioninsttype} SectionInstType |
| 75 |
|
| 76 |
\c insttype_index [insttype_index [...]] [RO] |
| 77 |
|
| 78 |
This command specifies which install types (see \R{ainsttype}{InstType}) the current section defaults to the enabled state in. Multiple \cw{SectionInstType} commands can be specified (they are combined). If you specify RO as a parameter, then the section will be read-only, meaning the user won't be able to change its state. |
| 79 |
|
| 80 |
\c InstType "Full" IT_FULL |
| 81 |
\c InstType "Minimal" IT_MIN |
| 82 |
\c |
| 83 |
\c Section "Help" |
| 84 |
\c SectionInstType ${IT_FULL} ${IT_MIN} |
| 85 |
\c SectionEnd |
| 86 |
\c |
| 87 |
\c Section "Bonus content" |
| 88 |
\c SectionInstType ${IT_FULL} |
| 89 |
\c SectionEnd |
| 90 |
|
| 91 |
\S2{ssectionin} SectionIn |
| 92 |
|
| 93 |
\c insttype_index [insttype_index [...]] [RO] |
| 94 |
|
| 95 |
Works like \cw{SectionInstType} except that the first install type defined using \R{ainsttype}{InstType} is indexed 1, the next 2 and so on. |
| 96 |
|
| 97 |
\# DEPRECATED |
| 98 |
|
| 99 |
\S2{ssectiongroup} SectionGroup |
| 100 |
|
| 101 |
\c [/e] section_group_name [index_output] |
| 102 |
|
| 103 |
This command inserts a section group. The section group must be closed with \R{ssectiongroupend}{SectionGroupEnd}, and should contain 1 or more sections. If the section group name begins with a !, its name will be displayed with a bold font. If /e is present, the section group will be expanded by default. If \e{index_output} is specified, the parameter will be !defined with the section index (can be used with \R{sectionsettext}{SectionSetText} etc). If the name is prefixed with 'un.' the section group is an uninstaller section group. |
| 104 |
|
| 105 |
\c SectionGroup "some stuff" |
| 106 |
\c Section "a section" |
| 107 |
\c SectionEnd |
| 108 |
\c Section "another section" |
| 109 |
\c SectionEnd |
| 110 |
\c SectionGroupEnd |
| 111 |
|
| 112 |
\S2{ssectiongroupend} SectionGroupEnd |
| 113 |
|
| 114 |
Closes a section group opened with \R{ssectiongroup}{SectionGroup}. |