Saved Bookmarks
| 1. |
Solve : Max number of tokens? |
|
Answer» Quote from: ValerieMay on July 19, 2009, 03:53:21 PM I'm not sure where your quoted code comes from From typing FOR /? at the prompt Quote %i is explicitly declared in the for statement and the %j and %k This is also in ntcmds.chm, (type hh ntcmds.chm at the prompt - but this was removed from Vista & later I believe) and online at http://technet.microsoft.com/en-us/library/bb490909.aspx but a quick look in the Google Groups archive of alt.msdos.batch.nt reveals that the 31 character undocumented "feature" is well known. For example this thread http://tinyurl.com/l7cqbc Personally I might feel a little nervous about using, in production code, an undocumented feature like this, unless I was sure that MS would never alter cmd.exe in a way that breaks it. If it has persisted to Vista and Windows 7 then maybe... confirmed: ntcmds.chm is not in Windows Vista. (although the CHM help viewer is)Salmon Trout - Thank you for your comments. I guess I'll just wait for the axe to fall if M$ does decide to remove the undocs from Cmd.exe. M$ history doesn't reveal an eagerness to remove undocs, even those in MS-Dos versions, but who can tell. As far as I can remember I've never used the Tokens=1-31 feature but have certainly used vars outside the alphabet such as %%0 thru' %%9 and odd chars like %%# and %%$. M$ is long overdue to update their Help info rather then remove undocs!!. VM.here is my code, but its the same as @Salmon Trout, lol Code: [Select]@echo off set INPUT=01074 02 03 04 0578 063 07 08 09 1045 11 12 13 14 152345 16 17 18 19 20 21 22 23 24.29 25 26 27 28 29 30 31 32 33 34 35 36 37 38.75 39 40 :MAINLOOP set /p wTok=Token: call :GetToken %input% echo.%rTok% goto MAINLOOP :GetToken set num=0 set rTok= :LOOP set /a num+=1 if %num% equ %wTok% set rTok=%1 shift if not "%1" equ "" goto LOOP i think its the best way to do thisQuote from: devcom on July 21, 2009, 07:02:53 AM i think its the best way to do thisin batch, that is. Otherwise, definitely not.I realise you probably have your desired solution now, but here is one using REXX. This is an interpreted language suitable for avoiding complex DOS commands, and REXX progrrams can ISSUE DOS commands from within. The REXX processor R4 which I use is obtainable free, here: http://www.kilowattsoftware.com/ infile = "input file.txt" outfile = "output file.txt" dosoutfile = '"'outfile'"' 'if exist' dosoutfile 'del' dosoutfile do i = 1 for lines(infile) parse value linein(infile) with, . . . . . . . . . . . . . . . . . . . ., . . . w24 . . . . . . . . . . . . . w38 . reply = lineout(outfile, w24 w38) end |
|