
    'demonstrate the files command

    'first predimension the array we need
    dim dir$(10,3)

    'now get the file info and stick it into the array
    files "c:\", "*.*", dir$()

    'items in dir$(0,?) now have information we can use
    qtyFiles = val(dir$(0, 0))
    print qtyFiles; " files"
    qtySubDirs = val(dir$(0, 1))
    print qtySubDirs; " subdirectories"
    print dir$(0, 2); dir$(0, 3)

    if qtyFiles = 0 then [printSubdirectoryInfo]

    'reformat the file information
    for x = 1 to qtyFiles
        dir$(x, 1) = right$("        " + dir$(x, 1), 9)
    next x

    'now sort the files in the array
    sort dir$(), 1, qtyFiles, 1

    'now print out the file information
    for x =  qtyFiles to 1 step -1
        print left$(dir$(x, 0) + "            ", 13) ; "  "; dir$(x, 1); "  "; dir$(x, 2)
    next x

[printSubdirectoryInfo]

    print
    print "Subdirectories:"
    if qtySubDirs > 0 then
        for x = qtyFiles + 1  to qtyFiles + qtySubDirs
            print dir$(x, 1)
        next x
    else
        print "No subdirectories."
    end if

    end

