For and 52 active vars at one time

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Cleptography
Posts: 287
Joined: 16 Mar 2011 19:17
Location: scriptingpros.com
Contact:

For and 52 active vars at one time

#1 Post by Cleptography » 27 May 2011 00:22

I am not understanding why under the help context it says you can only have 52 active values defined at one time provided they are between Aa - Zz when other chars are available past that point... :?:

Code: Select all

@echo off

REM WORKS:           ` ~ ! @ # $ * ) - _ + [ { ] } \ : ' . / ?
REM DOES NOT WORK:   % ^ & ( = | ; " , < >
REM 83 not including the other available chars through charmap
REM 0-9

for /d %%a in (1 2 3 4 5) do (
for /d %%b in (%%a) do (
for /d %%c in (%%b) do (
for /d %%d in (%%c) do (
for /d %%e in (%%d) do (
for /d %%f in (%%e) do (
for /d %%g in (%%f) do (
for /d %%h in (%%g) do (
for /d %%i in (%%h) do (
for /d %%j in (%%i) do (
for /d %%k in (%%j) do (
for /d %%l in (%%k) do (
for /d %%m in (%%l) do (
for /d %%n in (%%m) do (
for /d %%o in (%%n) do (
for /d %%p in (%%o) do (
for /d %%q in (%%p) do (
for /d %%r in (%%q) do (
for /d %%s in (%%r) do (
for /d %%t in (%%s) do (
for /d %%u in (%%t) do (
for /d %%v in (%%u) do (
for /d %%w in (%%v) do (
for /d %%x in (%%w) do (
for /d %%y in (%%x) do (
for /d %%z in (%%y) do (
for /d %%A in (%%z) do (
for /d %%B in (%%A) do (
for /d %%C in (%%B) do (
for /d %%D in (%%C) do (
for /d %%E in (%%D) do (
for /d %%F in (%%E) do (
for /d %%G in (%%F) do (
for /d %%H in (%%G) do (
for /d %%I in (%%H) do (
for /d %%J in (%%I) do (
for /d %%K in (%%J) do (
for /d %%L in (%%K) do (
for /d %%M in (%%L) do (
for /d %%N in (%%M) do (
for /d %%O in (%%N) do (
for /d %%P in (%%O) do (
for /d %%Q in (%%P) do (
for /d %%R in (%%Q) do (
for /d %%S in (%%R) do (
for /d %%T in (%%S) do (
for /d %%U in (%%T) do (
for /d %%V in (%%U) do (
for /d %%W in (%%V) do (
for /d %%X in (%%W) do (
for /d %%Y in (%%X) do (
for /d %%Z in (%%Y) do (
for /d %%± in (%%Z) do (
echo.%%±
)))))))))))))))))))))))))))))))))))))))))))))))))))))

What am I missing here, thank you.

orange_batch
Expert
Posts: 442
Joined: 01 Aug 2010 17:13
Location: Canadian Pacific
Contact:

Re: For and 52 active vars at one time

#2 Post by orange_batch » 27 May 2011 05:37

It's for for /f using token sets. It assigns tokens past the letter you define alphabetically.

Code: Select all

@echo off
for /f "delims=, tokens=1-60" %%a in ("1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60") do (
echo:%%a . %%b . %%c . %%d . %%e . %%f . %%g . %%h . %%i . %%j
echo:%%k . %%l . %%m . %%n . %%o . %%p . %%q . %%r . %%s . %%t
echo:%%u . %%v . %%w . %%x . %%y . %%z . %%A . %%B . %%C . %%D
echo:%%E . %%F . %%G . %%H . %%I . %%J . %%K . %%L . %%M . %%N
echo:%%O . %%P . %%Q . %%R . %%S . %%T . %%U . %%V . %%W . %%X
echo:%%Y . %%Z
echo:
echo:What would come after the alphabet...?
echo:
)

for /f "delims=, tokens=1-26" %%a in ("1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26") do (
for /f "delims=, tokens=1-26" %%A in ("27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52") do (
echo:%%a . %%b . %%c . %%d . %%e . %%f . %%g . %%h . %%i . %%j
echo:%%k . %%l . %%m . %%n . %%o . %%p . %%q . %%r . %%s . %%t
echo:%%u . %%v . %%w . %%x . %%y . %%z . %%A . %%B . %%C . %%D
echo:%%E . %%F . %%G . %%H . %%I . %%J . %%K . %%L . %%M . %%N
echo:%%O . %%P . %%Q . %%R . %%S . %%T . %%U . %%V . %%W . %%X
echo:%%Y . %%Z
))
echo:
echo:Here we have 52 defined simultaneously.
echo:
Last edited by orange_batch on 27 May 2011 06:16, edited 3 times in total.

jeb
Expert
Posts: 1055
Joined: 30 Aug 2007 08:05
Location: Germany, Bochum

Re: For and 52 active vars at one time

#3 Post by jeb » 27 May 2011 06:12

orange_batch wrote:It's for for /f using token sets. It assigns tokens past the letter you define alphabetically.
orange_batch wrote:What would come after the alphabet...?

Code: Select all

for /f "delims=, tokens=1-31" %%!  in (
   "1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31") do (
   echo %%! . %%" . %%# . %%$ . %%~%% . %%& . %%' . %%( . %%) . %%* . %%+ . %%, . %%- . %%. . %%/
   echo %%0 . %%1 . %%2 . %%3 . %%4 . %%5 . %%6 . %%7 . %%8 . %%9
   echo %%: . %%; . %%^< . %%= . %%^> . %%? . %%@
   echo(

)


You can create any character as an for-loop var, but sometimes it's a bit complicated to access them.. (like the the %%~%%)

jeb

orange_batch
Expert
Posts: 442
Joined: 01 Aug 2010 17:13
Location: Canadian Pacific
Contact:

Re: For and 52 active vars at one time

#4 Post by orange_batch » 27 May 2011 06:14

Indeed, I wasn't gonna check.

Also I'm getting lazy, forgot about the m-n syntax.

I will say though, it's more complicated to try to get past 52 tokens than it is to just process a line multiple times, or set up a repeat token-by-token function.

Cleptography
Posts: 287
Joined: 16 Mar 2011 19:17
Location: scriptingpros.com
Contact:

Re: For and 52 active vars at one time

#5 Post by Cleptography » 27 May 2011 12:07

Thank you jeb, and orange your insight has been very helpful. Does this same logic apply for the rest of the chars
not available from the keyboard?

orange_batch
Expert
Posts: 442
Joined: 01 Aug 2010 17:13
Location: Canadian Pacific
Contact:

Re: For and 52 active vars at one time

#6 Post by orange_batch » 30 May 2011 00:57

No idea, but I doubt it. 8)

Post Reply