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,729 of 68,980    |
|    Tom Del Rosso to All    |
|    Re: leading zero    |
|    08 Mar 21 14:54:43    |
      From: fizzbintuesday@that-google-mail-domain.com              JJ wrote:       > On Sun, 7 Mar 2021 09:28:16 -0500, Tom Del Rosso wrote:       >>       >> But this doesn't explain (it seems to me) why the variable without       >> percents has a different result. SET/A is supposed to behave the same       >> with or without the percents.       >       > With below command...       >       > set /a y=%x%       >       > The reason why it causes an error is because CMD performs syntax       > check then expands any expandable variable references (which uses the       > percent sign), THEN it executes the command.       >       > So, if x variable contain 09, the command line would be like below       > before it's executed.       >       > set /a y=09       >       > Meaning, the given value is a constant, rather than a variable name,       > from the perspective of the SET /A command.              I know that, but it should do the same with              set /a y=x              As it says in the set help, "Any non-numeric strings in the expression       are treated as environment variable names whose values are converted to       numbers before using them."              So the conversion is done incorrectly, producing zero as if the variable       was not denied at all.                     --        Defund the Thought Police              --- 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