How to? Correctly use defined test

Jun 11, 2008

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

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

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?

Jun 11, 2008
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.

Similar threads
Thread starter Title Forum Replies Date
M Oracle batch OPatch.bat.bat not working in TCC but correctly in CMD Support 5
vefatica Console popup windows don't work correctly Support 0
S Windows Server version not being detected correctly in TCMD 26RC2 Support 9
Peter Murschall WAD rem does not work correctly Support 8
K Batch debugger not stepping correctly Support 4
M WAD PDir not working correctly... Support 5
R WAD /= size ranges not set correctly Support 5
M Is @AltName working correctly? Support 9
T Transparency in IDE not working correctly Support 4
S CON: not processed correctly in @FILEREAD and @FILEARRAY Support 1
x13 Function to get interface user-defined name? Support 10
M User defined language file for Notepad++ ? Support 3
S Documentation "DEFINED" vs. array elements Support 1
dcantor How to transfer defined keystrokes Support 2
krischik %@if[DEFINED Support 2
p.f.moore Quoting arguments to a user defined function Support 4
M Selecting test "off by one" problem in Take command Support 4
T unqlite binary read test is inconsistent Support 2
Joe Caverly Conditional Expression Test of @SFN Support 4
S How to? How can I test "if isdir"/"if isfile" tests on an HTTP site? Support 2
M Just a verification regarding "Iff" and both "status test(s)" and "relational expression(s)"... Support 3
rconn 13.0.18 Test build for VIEW problem Support 23
rconn 13.0.17 Test build for VIEW problem in 16 Support 2
dcantor New conditional test in TCC 12.10 Support 2
newbie Test to ensure aliases are loaded Support 6
rconn v12 Release Build test - 32-bit fixed Support 36
rconn v12 Release Build test Support 4
rconn Take Command 10.0.66 beta test Support 8
rconn Windows 7 test fix Support 12
vefatica Indent test Support 1
vefatica Just a test Support 8

Similar threads