Winamp & Shoutcast Forums

Winamp & Shoutcast Forums (http://forums.winamp.com/index.php)
-   NSIS Discussion (http://forums.winamp.com/forumdisplay.php?f=65)
-   -   validate macro parameters at compile time? (http://forums.winamp.com/showthread.php?t=233973)

MikeSchinkel 25th December 2005 02:08

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:

code:

!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 25th December 2005 09:55

I wasn't able to find the topic which has the solution to this, but here is what you do.

code:
!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

MikeSchinkel 25th December 2005 17:33

Stu, you are the best, thanks!

dandaman32 25th December 2005 21:12

I never tried this, but can symbol names have spaces?

-dandaman32

deguix 26th December 2005 12:33

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}:

code:

OutFile Test.exe

!define "AB CD" 1234

Section
MessageBox MB_OK ${AB CD}
SectionEnd



All times are GMT. The time now is 04:57.

Copyright © 1999 - 2010 Nullsoft. All Rights Reserved.