Simple .bat question - dump contents of 2 dimensional array

ccb

Jul 13, 2009
44
0
#1
>ver
TCC 13.03.37 x64 Windows 7 [Version 6.1.7601]

I haven't worked with a .bat/.cmd/.btm file in a long time...
I use the sift plugin to create an array:
Code:
>sift 10 largest biguns
10 largest files sifted into BIGUNS[10,3].
From the command line, this works as expected:
Code:
>do i = 0 to 3 (echo %BIGUNS[%i,0])
tmp1F8E.tmp
fla7C.tmp
~DF0A9116212CDE5BE1.TMP
tmpEF1A.tmp
However, when I try to do the same thing in a batch file (where __rowCnt and __arrName are parameters to the batch file):
Code:
set __arrName=%1
set __rowCnt=%2
do i = 0 to %__rowCnt (echo %__arrName[%i,0])
>c:\bin\dumpArray.bat BIGUNS 3
BIGUNS[0,0]
BIGUNS[1,0]
BIGUNS[2,0]
BIGUNS[3,0]
Thanks for any help...
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
3,599
46
Albuquerque, NM
prospero.unm.edu
#2
I don't see any straightforward way to do a delayed expansion of an array variable. Here's a nasty Rube Goldberg approach:

Code:
do i = 0 to %__rowCnt ( echo %@execstr[echo %%%__arrName[%i,0]] )
If you're also using my SafeChars plugin, you could also:

Code:
do i = 0 to %__rowCnt ( echo %@safeexp[%__arrName[%i,0]] )
Perhaps someone else can come up with something a little more elegant...?