home bbs files messages ]

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,740 of 42,547   
   Herbert Kleebauer to Anton Shepelev   
   Re: Turing-competeness of the batch lang   
   26 Aug 19 19:58:12   
   
   From: klee@unibwm.de   
      
   On 26.08.2019 18:54, Anton Shepelev wrote:   
   > Herbert Kleebauer:   
      
      
   > Why does the following script return 5 instead of 6?   
   >   
   > @echo off   
   > SETLOCAL ENABLEDELAYEDEXPANSION   
   > SET S=0;   
   > for /L %%i IN (1,1,3) DO SET /A S=!S!+%%i & echo Summing: %%i   
   > echo Result:  %S%   
      
   Because you should have used:   
      
   @echo off   
   SETLOCAL ENABLEDELAYEDEXPANSION   
   SET S=0   
   for /L %%i IN (1,1,3) DO SET /A S=!S!+%%i & echo Summing: %%i   
   echo Result:  %S%   
      
      
      
   > I mean in situation similar to the above.  For exam-   
   > ple, how to set a variable to a comma-separated list   
   > of files in a directory?   
      
   echo a>a.txt   
   echo b>b.txt   
   echo c>c.txt   
   set list=   
   for  %%i in (*.txt) do call set list=%%list%%,%%i   
   echo %list%   
      
   --- 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