Debian Codegraph @

Docs/src/script.but

raw
1 \C{scriptref} Scripting Reference
2
3 \H{fileformat} Script File Format
4
5 A NSIS Script File (.nsi) is just a text file with script code.
6
7 \\<b\\>Commands\\</b\\>
8
9 Commands lines are in the format 'command [parameters]'
10
11 \c File "myfile"
12
13 \\<b\\>Comments\\</b\\>
14
15 Lines beginning with ; or # are comments. You can put comments after commands. You can also use C-style comments to comment one or more lines.
16
17 \c ; Comment
18 \c # Comment
19 \c
20 \c # Comment \
21 \c Another comment line (see `Long commands` section below)
22 \c
23 \c /*
24 \c Comment
25 \c Comment
26 \c */
27 \c
28 \c Name /* comment */ mysetup
29 \c
30 \c File "myfile" ; Comment
31
32 If you want a parameter to start with ; or # put it in quotes.
33
34 If the first or second line in the file is a \#{pep263}comment with the following format, the rest of the file is decoded using the specified character set.
35
36 \c # -*- coding: utf-8 -*-
37
38 \\<b\\>Plug-ins\\</b\\>
39
40 To call a plug-in, use 'plugin::command [parameters]'. For more info see \R{plugindlls}{Plug-in DLLs}.
41
42 \c nsExec::Exec "myfile"
43
44 \\<b\\>Numbers\\</b\\>
45
46 For parameters that are treated as numbers, use decimal (the number) or hexadecimal (with 0x prepended to it, i.e. 0x12345AB), or octal (numbers beginning with a 0 and no x).
47
48 Colors should be set in hexadecimal RGB format, like HTML but without the #.
49
50 \c IntCmp 1 0x1 lbl_equal
51 \c
52 \c SetCtlColors $HWND CCCCCC
53
54 \\<b\\>Strings\\</b\\>
55
56 To represent strings that have spaces, use quotes:
57
58 \c MessageBox MB_OK "Hi there!"
59
60 Quotes only have the property of containing a parameter if they surround the rest of the parameter. They can be either single quotes, double quotes, or the backward single quote.
61
62 You can escape quotes using $\\:
63
64 \c MessageBox MB_OK "I'll be happy" ; this one puts a ' inside a string
65 \c MessageBox MB_OK 'And he said to me "Hi there!"' ; this one puts a " inside a string
66 \c MessageBox MB_OK `And he said to me "I'll be happy!"` ; this one puts both ' and "s inside a string
67 \c MessageBox MB_OK "$\"A quote from a wise man$\" said the wise man" ; this one shows escaping of quotes
68
69 It is also possible to put newlines, tabs etc. in a string using $\\r, $\\n, $\\t etc. \R{varstrings}{More information...}
70
71 \\<b\\>Variables\\</b\\>
72
73 Variables start with $. User variables must be declared.
74
75 \c Var MYVAR
76 \c
77 \c StrCpy $MYVAR "myvalue"
78
79 \R{variables}{More information...}
80
81 \\<b\\>Long commands\\</b\\>
82
83 To extend a command over multiple lines, use a backslash (\\) at the end of the line. The next line will effectively be concatenated to the end of it. For example:
84
85 \c CreateShortcut "$SMPROGRAMS\NSIS\ZIP2EXE project workspace.lnk" \
86 \c "$INSTDIR\source\zip2exe\zip2exe.dsw"
87 \c
88 \c MessageBox MB_YESNO|MB_ICONQUESTION \
89 \c "Do you want to remove all files in the folder? \
90 \c (If you have anything you created that you want \
91 \c to keep, click No)" \
92 \c IDNO NoRemoveLabel
93
94 Line extension for long commands works for comments as well. It can be a bit confusing, so it should be avoided.
95
96 \c # A comment \
97 \c still a comment here...
98
99 \\<b\\>Compiler Commands\\</b\\>
100
101 Compiler commands start with a ! and are executed at compile time.
102
103 \c !define MESSAGE "Hello"
104 \c
105 \c !ifdef MESSAGE
106 \c MessageBox MB_OK "${MESSAGE}"
107 \c !else
108 \c !error "MESSAGE not defined, cannot continue!"
109 \c !endif
110
111 \R{comptime}{More information...}
112
113 \\<b\\>Configuration file\\</b\\>
114
115 If a file named "nsisconf.nsh" in the config directory exists, it will be included by default before any scripts (unless the /NOCONFIG command line parameter is used). The config directory on Windows is the same directory as makensis.exe is in. On other platforms this is set at install time and defaults to $PREFIX/etc/. You can alter this at runtime, see \k{usageenvironment} for more information.