Old 20th December 2007, 00:45   #1
chjfth
Junior Member
 
Join Date: Feb 2007
Posts: 13
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)
chjfth is offline   Reply With Quote
Old 20th December 2007, 11:40   #2
{_trueparuex^}
Senior Member
 
{_trueparuex^}'s Avatar
 
Join Date: Dec 2005
Location: Glow
Posts: 285
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.

Last edited by {_trueparuex^}; 20th December 2007 at 12:29.
{_trueparuex^} is offline   Reply With Quote
Old 21st December 2007, 10:25   #3
chjfth
Junior Member
 
Join Date: Feb 2007
Posts: 13
Thank you very much. Your trick really works.
chjfth is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump