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,736 of 42,547   
   Anton Shepelev to All   
   Re: Turing-competeness of the batch lang   
   26 Aug 19 19:54:25   
   
   From: anton.txt@g{oogle}mail.com   
      
   Herbert Kleebauer:   
      
   >>>SET S=0;   
   >>>for /L %%i IN (1,1,5) DO SET /A S=S+%%i   
   >>>echo %S%   
   >>   
   >>So, does SET /A imply delayed expantion?  How do I   
   >>concatenate strings without delayed expansion?   
   >   
   >There is no expansion of S because neither %S%  nor   
   >!S!  is  used.  S is just a numeric variable use by   
   >"set /a".   
      
   Thank you for the answer.  %% and  !!  are  explicit   
   expansion  operators  that  replace  the name of `S'   
   with its value.  Since `SET  /A'  does  not  require   
   these operators, it substitutes the value of `S' in-   
   ternally or implicitly. That is still delayed expan-   
   sion,  because  the `S' is evaluated at every execu-   
   tion of SET /A.   
      
   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%   
      
   >>How do I concatenate strings without  delayed  ex-   
   >>pansion?   
   >   
   >set a=123   
   >set b=456   
   >set c=%a%%b%   
   >echo %c%   
      
   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?   
      
   --   
   ()  ascii ribbon campaign - against html e-mail   
   /\  http://preview.tinyurl.com/qcy6mjc [archived]   
      
   --- 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