if ($devent == init) {
var %dname = $dname, %| = |, %file = $+(",$scriptdir,playlist.txt"), $&
%dir = $iif($hget(playlist,dir), $ifmatch, $+(",$sdir(c:,choose an mp3 directory),") )
if ($$isdir(%dir)) { hadd -m playlist dir %dir }
if ($isfile(%file)) { .remove %file }
mdx SetMircVersion $version
mdx MarkDialog %dname
mdx SetFont %dname 4,5,6,7,8,9 Default 20 40 WebDings
if ($fopen(playlist)) { .fclose playlist }
.fopen -n playlist %file
[color:green]; Maybe the commands inside $findfile() could be faster if put inside an alias.
; I didn't bother to check which method would be faster.
; Check it yourself, it's worth it, since this is the most important part of the code..
; P.S.: Remove the $&, this is just to avoid messing up the board.[/color]
.echo -q $findfile(%dir,*.mp3,0, $&
.fwrite -n playlist $+(",$1-,") [ %| ] did -a %dname 10 $left($nopath($1-),-4) )
[color:green]; This $findfile() below could be $did(%dname,10).lines,
; but I'm not sure since you're using MDX.[/color]
hadd -m playlist total $findfile(%dir,*.mp3,0)
if ($inmp3) {
did -a %dname 3 $left($nopath($inmp3.fname),-4) $+ , $asctime($calc($inmp3.length / 1000),n:ss)
did -c %dname 10 %i
}
}