You are here

Syntax in a NSIS script file

8 posts / 0 new
Last post
tapsklaps
Offline
Last seen: 5 years 6 months ago
Developer
Joined: 2010-10-17 08:11
Syntax in a NSIS script file

Due to usage of the NSIS Logic Library (implemented by the command
"!include LogicLib.nsh" in the *.nsi sript file) I often encountered constructs, which contain the 3 characters "$", "{" and "}".

Typical examples are:

  • ${If}
  • ${EndIf}
  • ${FileExists}
  • ${WordReplace}
  • ${SetEnvironmentVariable}
  • ${SegmentInit}
  • ${SegmentPrePrimary}

But in which cases is it necessary to use these characters and why I can omit these characters in connection with the following instructions:

  • CopyFiles
  • WriteINIStr
Gord Caswell
Gord Caswell's picture
Offline
Last seen: 5 months 2 days ago
DeveloperModerator
Joined: 2008-07-24 18:46
NSIS user manual

The ones that are like ${something} are variables, set either within NsIS itself, within LogicLib or one of the other included headers, or within PAL, not specific to anywhere else.

The other ones are commands within NSIS, not variables. For more information, check out the NSIS user's manual, particularly chapter 4.

http://nsis.sourceforge.net/Docs/

tapsklaps
Offline
Last seen: 5 years 6 months ago
Developer
Joined: 2010-10-17 08:11
Declaration and value of some variables

Is it really so, that for example ${FileExists} is a variable? And if so, where is declared this variable? In the article regarding LogicLib is only mentioned, that the expression ${FileExists} is a condition. And what is the value of this variable ${FileExists}?

Furthermore is in documentation of NSIS a by "VAR = example" declared variable later used as "$example", i.e. without the both characters "{" and "}".

Gord Caswell
Gord Caswell's picture
Offline
Last seen: 5 months 2 days ago
DeveloperModerator
Joined: 2008-07-24 18:46
Right, sorry

Right, sorry, I was answering from my phone, answered quickly.

${If}...${EndIf} and the variations on those, as well as ${FileExists} are LogicLib conditional statements, to be used as listed on the LogicLib page you linked to.

${WordReplace} is a macro found in the headers, WordFunc.nsh, I believe.

${SetEnvironmentVariable} & ${Segment...} are macros created by PAL.

Whereas CopyFiles and WriteINIStr are instructions within NSIS itself.

tapsklaps
Offline
Last seen: 5 years 6 months ago
Developer
Joined: 2010-10-17 08:11
understandable explanation

You've only explained me the meaning of the expressions, which I listed in my original post. But this explanation not answered my main question, why the 3 characters "$", "{" and "}" are used.

In the meantime I received an understandable answer in the Winamp NSIS forum. The compiler maintains a list of defined symbols, which can be defined using !define. To replace a symbol with its value, use ${SYMBOL}. For more informations please look in chapter 5.4 of the documentation of NSIS.

Other functions like CopyFiles are native functions, which the NSIS compiler "makeNSIS.exe" knows about and they are documented in the main helpfile...

tapsklaps
Offline
Last seen: 5 years 6 months ago
Developer
Joined: 2010-10-17 08:11
Explanations with respect to the expression ${WordReplace}

In the chapter E.3.8 WordReplace of the NSIS documentation I found fundamental explanations with respect to the expression ${WordReplace}.

tapsklaps
Offline
Last seen: 5 years 6 months ago
Developer
Joined: 2010-10-17 08:11
documentation with respect to macros created by PAL

But where can I find some helpful explanations to the following expressions?

  • ${SetEnvironmentVariable}
  • ${SegmentInit}
  • ${SegmentPrePrimary}
  • ${SegmentPreExec}
  • ${SegmentPreSecondary}
  • ${SegmentPostPrimary}
  • ${SegmentPostSecondary}
  • ${SegmentUnload}
Gord Caswell
Gord Caswell's picture
Offline
Last seen: 5 months 2 days ago
DeveloperModerator
Joined: 2008-07-24 18:46
manual & code

Some of those are explained in the manual, others you need to dig in the code for more explanation. Note that the code doesn't have specific explanations of what's it's doing, just generic comments.

Log in or register to post comments