John,

I,m kinda embarrassed with this one because it's so low-tech and it doesn't use arrays ... it uses the "indexed file" type behaviors of INI files to keep a tally of extention stats ... probably be a real performance pig after a while too ...

And your right, the only other way I can think to do it is with arrays (which means array lookups as well) or with dynamic coding with the execute function (like your orginal thought) ... both are totally doable but at what cost ? (performance/maintainability, all that) ?


It's written with KiXtart 4.1 (have to have the latest because of the instrrev() function) ...


break on


$profile = "@curdir\enumdir.ini"
$tempfile = "@curdir\enumdir.tmp"


$search = "c:\*.doc;c:\*.kix"


shell '%comspec% /c dir $search /s/b >"$tempfile"'


$= writeprofilestring($profile,"dirs","","") ; clear list


if open(1,$tempfile) = 0
$filename = readline(1)
while @error = 0
if $filename
$extention = substr($filename,instrrev($filename,".")+1,3)
$total = val(readprofilestring($profile,"dirs",$extention))
$total = $total + getfilesize($filename)
$= writeprofilestring($profile,"dirs",$extention,$total)
endif
$filename = readline(1)
loop
$=close(1)
endif


for each $extention in split(readprofilestring($profile,"dirs",""),chr(10))
if $extention
?"$extention has " readprofilestring($profile,"dirs",$extention) " bytes used"
endif
next


exit

Anyway, food for thought eh ?

-Shawn