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.

138 views      
 

Messages in this Thread

 
94,242 Postings in 11,887 Threads, 347 registered users, 10 users online (1 registered, 9 guests)
Index | Admin contact |   Forum Time: Apr 18, 2019 - 3:23 pm EDT  |  Hits:27,505,987  (1,917 Today )
RSS Feed