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.

92 views      
 

Messages in this Thread

 
93,933 Postings in 11,850 Threads, 347 registered users, 8 users online (0 registered, 8 guests)
Index | Admin contact |   Forum Time: Dec 10, 2018 - 3:57 pm EST  |  Hits:26,926,174  (2,642 Today )
RSS Feed