Winamp & Shoutcast Forums

Winamp & Shoutcast Forums (http://forums.winamp.com/index.php)
-   NSIS Discussion (http://forums.winamp.com/forumdisplay.php?f=65)
-   -   How to check env-var on compile time (http://forums.winamp.com/showthread.php?t=283456)

chjfth 20th December 2007 00:45

How to check env-var on compile time
 
HELP. I'd like to check whether an environment variable is defined when compiling an nsi file(because which files to pack relies on that env-var).

To check env-var UTBS, I tried :

code:

!if "$%UTBS%" == ""
!echo "Env-var UTBS is not defined. I cannot continue."
!else
!echo "Env-var UTBS is defined to $%UTBS%"
!endif




If UTBS is defined, NSIS compiler outputs what we expect, i.e. %UTBS% is replaced with what UTBS's value is.

But if UTBS is not defined, it outputs

Quote:

Processing script file: "checkenv.nsi"
Env-var UTBS is defined to $%UTBS% (checkenv.nsi:5)
That is not I'm expecting.

What can I do? (using NSIS v2.31)

{_trueparuex^} 20th December 2007 11:40

Edit: My workaround... It didn't work. :)

Edit 2:
Okay this one should work...
code:
!define S $

!if "$%UTBS%" == "${S}%UTBS%"
!echo "Env-var UTBS is not defined. I cannot continue."
!else
!echo "Env-var UTBS is defined to $%UTBS%"
!endif


In compile time $$ constants doesn't work in front of the environment variable. So using !if "$%UTBS%" == "$$%UTBS%" didn't work.

chjfth 21st December 2007 10:25

Thank you very much. Your trick really works.


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

Copyright © 1999 - 2010 Nullsoft. All Rights Reserved.