home bbs files messages ]

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 68,804 of 68,980   
   Herbert Kleebauer to Anton Shepelev   
   Re: Replacing a character with a percent   
   30 May 24 17:00:17   
   
   From: klee@unibwm.de   
      
   On 30.05.2024 12:33, Anton Shepelev wrote:   
      
   >> and if VAR doesn't have any spaces or other delimiters und   
   >> there are only single #, than this should work (but what   
   >> is wrong with delayed expansion?):   
   >   
   > I consider this additional limitation as a challenge.   
      
   Batch programming is always a challenge.   
      
   >   
   >> set var=a#b#c   
   >>   
   >> set var2=%var:#= %&set var=&   
   >> for %%i in (%var2%) do call set var=%%var%%%%i%%%%   
   >> set var=%var:~0,-1%   
   >>   
   >> echo %var%   
      
      
   > The `&' in `set var=&' seems   
   > unnecessary.  Is it there to avoid potential trailing   
   > whitespace?   
      
   Yes.   
      
   But why do you want to do it without delayed expansion?   
   You don't have to use it for the complete batch code,   
   just for the replacement of the #:   
      
   set var=a#b##c   
      
   setlocal enabledelayedexpansion&set p=%%&set var=%var:#=!p!%   
   endlocal&set var=%var%   
      
   echo %var%   
      
   --- 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