Reputation: 761
For example, is there a way to do something along these lines?
Eval "MessageBox MB_OK 'Hello, World!'"
This is obviously a useless example, but I feel that such functionality would be useful.
Upvotes: 0
Views: 72
Reputation: 101666
The NSIS compiler (MakeNSIS) parses text files and writes out binary instructions into the generated setup. The setup application itself can only execute the instructions known at compile time.
Most instructions accept variables as their parameters so you can get different behavior. Here is a rather pointless example of that:
Page InstFiles
Function MaybeShowMessageBox
IntCmp $0 0 skip
MessageBox MB_OK "$1"
skip:
FunctionEnd
Section
StrCpy $0 1 ; Display it
StrCpy $1 "Hello World"
Call MaybeShowMessageBox
StrCpy $1 "Goodbye World"
Call MaybeShowMessageBox
StrCpy $0 0 ; Don't display it
Call MaybeShowMessageBox
StrCpy $0 0
StrCpy $2 "$WinDir" 1 ; Get the first character
StrCmp $2 "C" "" skipWinDirMessage
StrCpy $0 1
skipWinDirMessage:
StrCpy $1 "$WinDir is on drive C"
Call MaybeShowMessageBox
SectionEnd
You would ordinarily never write code like that. IntFmt
is as close to Eval as you are going to get but it only operates on numbers:
ShowInstDetails show
Section
StrCpy $1 42
IntFmt $0 "%d" $1
DetailPrint "$1 as a number: $0"
IntFmt $0 "%#.4x" $1
DetailPrint "$1 as a hex number with a >= 4 width: $0"
IntFmt $0 "%c" $1
DetailPrint "$1 as a character: $0"
SectionEnd
Upvotes: 2