Forums before death by AOL, social media and spammers... "We can't have nice things"
|    alt.msdos.batch    |    Fun with MS-DOS batch files    |    42,547 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 41,482 of 42,547    |
|    foxidrive to Jean-Pierre Coulon    |
|    Re: SET in a loop in a script is ignored    |
|    10 Oct 16 23:01:44    |
      From: foxidrive@server.invalid              On 10.10.2016 08:33, Jean-Pierre Coulon wrote:       >> why can't I change a variable ? If I type set/a mavar=some expression       before,       >> the result comes at each ECHO line.       >>       >> for /L %%a in (1, 1, 5) do (       >> (set /a myvar="2*%%a+1")       >> echo %myvar%)                      > Type "set /?" for am explanation and what to do.                     I'll add some breadcrumbs here. Hansel and Gretel would appreciate it.                     @echo off       for /L %%a in (1, 1, 5) do (set /a myvar="2*%%a+1" & call echo %%myvar%%)       pause       for /L %%a in (1, 1, 5) do (set /a myvar="2*%%a+1" & echo "%myvar%")       pause       for /L %%a in (1, 1, 5) do (set /a myvar="2*%%a+1" & call echo %%myvar%%)       pause       setlocal enabledelayedexpansion       for /L %%a in (1, 1, 5) do (set /a myvar="2*%%a+1" & echo !myvar!)       pause              --- 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