Reputation: 2031
So this is a really basic question, but I can't seem to find what I am doing wrong.
So I am fiddling with defines in NSIS and it did not work as I would expect so I have scaled down the problem to its smallest part and I still can not make it work as I would expect.
Script looks as follows:
!ifndef b
!define b ""
!endif
!if $b=="b"
!define a "b"
!else
!define a "c"
!endif
Section
MessageBox MB_OK "a: ${a} b: ${b}"
SectionEnd
I run it with the flag /Db=b
.
The output is still:
a: "c" b: "b"
I am missing something trivial here!
Upvotes: 1
Views: 62
Reputation: 4048
b is a define, not a variable:
!ifndef b
!define b ""
!endif
!if "${b}" == "b" # <-- Modify this line.
!define a "b"
!else
!define a "c"
!endif
Section
MessageBox MB_OK "a: ${a} b: ${b}"
SectionEnd
Also, I recommend you quote everything when using if
because it'll give an error if define (or value of variable) is empty.
Upvotes: 2