ZTree.com  | ZEN  | About...  

 Index   Back

[Q] REM #ZTStart "" behavior changes or something else like a bug?   [Q]

By: Andrew Penfold     Hampshire, UK  
Date: Oct 06,2018 at 17:43
In Response to: [Q] REM #ZTStart "" behavior changes or something else like a bug? (Ryan)

> AA=
> REM #ZTStart ""
> REM #ZTSet VAR AAAAAA do not type 1 but just press enter to bypass=
> IF /I %VAR%==1 ECHO ddddd
> pause
>
>
> BB=
> REM #ZTStart ""
> REM #ZTSet VAR AAAAAA do not type 1 but just press enter to bypass=
> IF /I "%VAR%"=="1" ECHO ddddd
> pause
>
>
> why does AA= cause an error? while BB= works well.


Because environment variables (using %) are expanded to their values before executing the statement. So because you don't enter anything for the value of %VAR%, it is expanded to null

So the statement then reads

IF /I ==1 ECHO ddddd

which results in a syntax error.

But the second statement reads

IF /I ""=="1" ECHO ddddd

which parses fine.

302 views      
Thread locked
 

Messages in this Thread

 
95,065 Postings in 11,983 Threads, 350 registered users, 133 users online (0 registered, 133 guests)
Index | Admin contact |   Forum Time: Aug 3, 2020 - 11:21 pm EDT  |  Hits:32,811,337  (34,538 Today )
RSS Feed