1.

Solve : If not defined statement not working.?

Answer»

Okay, in one of my batch files. If the user does not put an input I WANT it to go to the same question. So here's what I'm doing.

Code: [Select]if not defined "%VARIABLE%" goto question

However it is always undefined. Or am I not using the right command for this KIND of thing.
well think of it this way, when you use the SET command, you are declaring a variable, if the variable doesnt exist then SET creates a memory area deticated to that variable.

so just because nothing was INPUTED means that its defined, usually its NUL value or 0 if nothing is set to that variableDuh, why wasn't I thinking of this before .

Code: [Select]if "%variable%"=="" goto label
Quote

Duh, why wasn't I thinking of this before

In the first post you were trying to find out if a variable existed, the second you are dealing with the value of a variable.

Your first post works with this syntax:

Code: [Select]if not defined variable goto question



Well, I just heard of using defined in an if statement. I was thinking it did a completely different thing.


Discussion

No Comment Found