Ray Yates
: mivascript at, pcinet d0t com
09/12/2011 21:19 p.m.
09/12/2011 21:19 p.m.
This add-on to the dir() function adds a simple filter for file extensions.
<MvFUNCTION
NAME
="
Read_Dir
"
PARAMETERS
="
path, ext, loc, filelist var
"
STANDARDOUTPUTLEVEL
=""
>
<MvIF
EXPR
="
{ dir(l.path, l.loc, l.files) LT 3 }
>"
<MvFUNCRETURN
VALUE
=""
>
</MvIF>
<MvASSIGN
NAME
="
l.extlen
"
VALUE
="
{ len(l.ext) }
>"
<MvCOMMENT> Ignore ./ and ../ and filter out non matching extensions </MvCOMMENT>
<MvFOREACH
ITERATOR
="
l.file
"
ARRAY
="
l.files
"
INDEX
="
l.pos
"
FIRST
="
{ 3 }
>"
<MvASSIGN
NAME
="
l.filelen
"
VALUE
="
{ len(l.file) }
>"
<MvIF
EXPR
="
{ substring(l.file, l.filelen - l.extlen + 1, l.extlen) EQ l.ext }
>"
<MvASSIGN
NAME
="
l.ndx
"
VALUE
="
{ l.ndx + 1 }
>"
<MvASSIGN
NAME
="
l.filelist
"
INDEX
="
{l.ndx}
"
VALUE
="
{ l.file }
>"
</MvIF>
</MvFOREACH>
<MvFUNCTIONRETURN
VALUE
="
{ miva_array_collapse(l.filelist) }
>"
</MvFUNCTION>