|
|
#1 |
|
Junior Member
Join Date: Sep 2014
Posts: 5
|
A totally n00b question, if you please?
Hi folks,
New to NSIS, and I have what no doubt is a totally dumb syntactical question. If I have this definition of a constant: code: Under what conditions would I need this construct, with the ${} to reference the value, as in: code: or this definition of a variable: code: Under what conditions would I need the ${} construct to reference the variable, when I can do something like: code: So, purely a syntactical question; what purpose does the ${} construct serve in NSIS script? Thanks in advance! DDoutelMS |
|
|
|
|
|
#2 | ||
|
Major Dude
Join Date: May 2005
Location: New Zealand
Posts: 916
|
Quote:
Quote:
"Only a MouseHelmet will save you from a MouseTrap" -Jason Ross (Me) NSIS 3 POSIX Ninja Wiki Profile |
||
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Sep 2014
Posts: 5
|
Thanks, Jason! I think that covers it! Much appreciated.
DDoutelMS |
|
|
|
|
|
#4 |
|
Major Dude
Join Date: May 2005
Location: New Zealand
Posts: 916
|
Forgot to mention that you can nest defines as well, like this:
code: A more dynamic example: code: "Only a MouseHelmet will save you from a MouseTrap" -Jason Ross (Me) NSIS 3 POSIX Ninja Wiki Profile |
|
|
|
|
|
#5 | |
|
Junior Member
Join Date: Sep 2014
Posts: 5
|
Quote:
|
|
|
|
|
|
|
#6 |
|
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,449
|
${define}
$variable $(langstring) IntOp $PostCount $PostCount + 1 |
|
|
|
|
|
#7 |
|
Junior Member
Join Date: Sep 2014
Posts: 5
|
|
|
|
|
|
|
#8 |
|
Major Dude
Join Date: Sep 2005
Location: Somewhere over the Slaughterhouse
Posts: 797
|
You can think of ${foo} as something that will be replaced with a fixed string at the moment when your .nsi script file gets compiled to an .exe file. So, yes, it's pretty much a constant. Note that you can also pass the "/Dfoo=something" parameter to makensis.exe to set the value of ${foo}. So it's useful for things you need to set at compile time. It's also similar to the preprocessor defines in C and C++.
Conversely, $X is a variable. So its value can still be changed at the time when your installer is actually running, e.g. via StrCpy. NSIS has the variables $0 to $1 as well as $r1 to $r9 that are available for general usage. Pretty much like "registers" in assembly language. Furthermore, there are special variables like $DESKTOP and so on that NSIS will fill with the corresponding path at runtime. You can also define your own variables via var something. Last but not least, $(bar) is for translatable strings that will be loaded from language file. See also: http://nsis.sourceforge.net/Docs/Chapter4.html#varother My Plugins: StdUtils | NSISList | CPUFeatures | ExecTimeout | KillProc My source of inspiration: http://youtu.be/lCwY4_0W1YI |
|
|
|
|
|
#9 | |
|
Junior Member
Join Date: Sep 2014
Posts: 5
|
Quote:
DDoutelMS |
|
|
|
|
![]() |
|
|||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|