Skip to content
⌘ NSIS Forum Archive

validate macro parameters at compile time?

5 posts

Guest#

validate macro parameters at compile time?

Is it possible to validate macro parameters at compile time? IOW, is there something like an "!ifequal" command and I just can't find it?

Here's an example showing what I'm looking for given the hypothetical !isequal command:


!macro foo _stmt _var1 _op _var2
!define _uid {__LINE__}
!ifequal _op "=" Continue${_uid}
!ifequal _op "<>" Continue${_uid}
!ifequal _op ">" Continue${_uid}
!ifequal _op "<" Continue${_uid}
!error "3rd param must be be one of: =, <>, <, or >."

Continue${_uid}:

...do work here

!undef _uid {__LINE__}
!macroend
Afrow UK#
I wasn't able to find the topic which has the solution to this, but here is what you do.

!macro A_Macro Param
!define "Check_${Param}"
!ifdef Check_Hello
# do something here
!else
# ...
!endif
!undef "Check_${Param}"
!macroend
This would check if the user passed "Hello".

-Stu
deguix#
Yes, if you put quotes around them. Their usage in instructions is weird though: you don't need to put quotes around the ${symbol w/ spaces}:


OutFile Test.exe

!define "AB CD" 1234

Section
MessageBox MB_OK ${AB CD}
SectionEnd