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,878 of 68,980    |
|    Anton Shepelev to All    |
|    Re: Comma in an argument value    |
|    05 Dec 24 11:51:27    |
   
   From: anton.txt@g{oogle}mail.com   
      
   Herbert Kleebauer to Anton Shepelev:   
      
   > > What does the following script:   
   > >   
   > > @ECHO OFF   
   > > FOR /F "tokens=2,* delims= " %%A in ("%*") DO SET ARGS=%%B   
   > > ECHO M:1:%1   
   > > ECHO M:2:%2   
   > > ECHO M:*:%ARGS%   
   > >   
   > > stored as test.bat invoked as   
   > >   
   > >> test.bat a "b,c" d e   
   > >   
   > > print:   
   > >   
   > > 1:a   
   > > 2:"b,c"   
   > > *:c" d e   
   > >   
   > > ?   
   >   
   > Remove the @ECHO OFF then you can see the executed command:   
   >   
   > FOR /F "tokens=2,* delims= " %A in ("a "b c" d e") DO SET ARGS=%B   
   >   
   > FOR /F ["options"] %variable IN ("string") DO command [command-parameters].   
   >   
   > Because the , is replaced by a space (why?), string becomes: a "b c" d e   
      
   Thanks. I have experimented some more and still have no   
   answer. It seems as though the comma is replaced by a space   
   only within the FOR invocation. If you asked "why?" as an   
   exercise for the reader, then failed it.   
      
   --   
   () ascii ribbon campaign -- against html e-mail   
   /\ www.asciiribbon.org -- against proprietary attachments   
      
   --- SoupGate-DOS v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca