Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

How to? Correctly use defined test

Jun
29
0
Hi

I recently tried to (unsuccessfully) to use "defined" like this:
Code:
setlocal
set var=%1

iff defined %var then
echo var defined as %var
else
echo var not defined
endiff

echo.
echo end defined test

This code always returns "var not defined". My expectation was that it should behave the same as if I had used "iff !%var! != !! then". What have I misunderstood about using defined?

John
 
Don't use the % in front of the variable name. (You were testing whether the contents of %var was an environment variable, not whether "var" was a defined variable.)
Thanks Rex, "var" is name of variable "%var" is content of var.

John
 
Back
Top
[FOX] Ultimate Translator
Translate