Forums before death by AOL, social media and spammers... "We can't have nice things"
|    alt.msdos.batch.nt    |    Fun with Windows NT batch files    |    68,980 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 67,447 of 68,980    |
|    Herbert Kleebauer to Petr Laznovsky    |
|    Re: if not condition    |
|    30 Jul 19 23:19:25    |
      From: klee@unibwm.de              On 30.07.2019 11:42, Petr Laznovsky wrote:              >>> if not "%b_level%"=="" (       >>>       >>> if %b_level% GTR 5 if %b_level% LEQ 18 set       "batt_level=1"              >>> variable b_level is empty, output of functions is:              > I wondering how the Delayed expansion affect this case, because       > 'b_level' variable is readed only inside of parenthesis, there is no       > manipulation with it.              I suppose the code between ( ) is parsed even if the "if not"       condition is not true. This means, if b_level is not defined,       the line:              if %b_level% GTR 5 if %b_level% LEQ 18 set "batt_level=1"              becomes:              if GTR 5 if LEQ 18 set "batt_level=1"              which gives a parsing error (it doesn't matter that       the code is not executed because of the "if not" statement).              With delayed expansion !b_level! is replaced at execution time       and not at parsing time and therefore there is no parsing error       and also no execution error (because the code isn't executed       because of the "if not" condition).              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca