'===========================================================================
' Subject: SHELL DIRECTORY LISTER             Date: 04-24-97 (10:42)       
'  Author: Nick Kochakian                     Code: QB, QBasic, PDS        
'  Origin: NickK@worldnet.att.net           Packet: DOS.ABC
'===========================================================================
DECLARE SUB getdirname ()
DECLARE SUB listall ()
DECLARE SUB refreshdir ()
DECLARE SUB listdir ()
DECLARE SUB printfile (a$)
DECLARE SUB mirrordir ()

'Directory Lister ver. 1.0
'
'4/24/97
'1997 By: - Nick Kochakian -
'
'This lists all the files of a directory
'I DO NOT recommend that you run this program while in your root directory,
'since there is too many files there.
'
'I am planning to make a better verison of this as time goes on!
'
'Any comments or questions should be e-mailed to: nickK@worldnet.att.net
'
'Note: It is recommended that you have MS-DOS 6.0 or higher! It may not matter
'      but it IS recommended!
DIM SHARED f
DIM SHARED e
f = 3000
e = 3000
DIM SHARED fil$(f)
DIM SHARED ext$(e)
DIM SHARED dirnam$

CLS

CALL refreshdir


PRINT dirnam$
CALL listall

SUB getdirname

' Directory of C:\NKBAS3 --- about line 4

OPEN "dir.lst" FOR INPUT AS #1

DO
INPUT #1, a$
a$ = UCASE$(a$)
LOOP UNTIL LEFT$(a$, 10) = " DIRECTORY" OR LEFT$(a$, 9) = "DIRECTORY"

alen = LEN(a$)

CLOSE #1

cnt = 1
DO
cnt = cnt + 1
LOOP UNTIL MID$(a$, cnt, 2) = "OF"

cnt = cnt + 3

DO
dirnam$ = dirnam$ + MID$(a$, cnt, 1)
cnt = cnt + 1
LOOP UNTIL cnt >= alen

END SUB

SUB listall

f = 1
e = 1

DO
PRINT fil$(f) + ext$(e)
f = f + 1
e = e + 1
LOOP UNTIL UCASE$(fil$(f)) = "/END" OR UCASE$(ext$(e)) = "/END"

END SUB

SUB listdir

OPEN "dir.lst" FOR INPUT AS #1

cnt = 1

LINE INPUT #1, b$

DO
LINE INPUT #1, a$
LOOP UNTIL a$ = ""

LINE INPUT #1, a$
LINE INPUT #1, a$

DO
LINE INPUT #1, a$

FOR i = 1 TO 41

IF MID$(a$, i, 5) = "bytes" THEN
f = f + 1
e = e + 1
fil$(f) = "/END"
ext$(e) = "/END"
CLOSE #1
EXIT SUB
END IF

IF MID$(a$, i, 5) = "BYTES" THEN
f = f + 1
e = e + 1
fil$(f) = "/END"
ext$(e) = "/END"

CLOSE #1
EXIT SUB
END IF

NEXT i

CALL printfile(a$)
a$ = ""
cnt = EOF(1)
LOOP UNTIL cnt = -1

CLOSE #1


END SUB

SUB mirrordir
'This makes a listing of the current directory

SHELL "dir *.* >dir.lst"

END SUB

SUB printfile (a$)

cnt = 1

DO
fil$(f) = fil$(f) + MID$(a$, cnt, 1)
cnt = cnt + 1
LOOP UNTIL cnt >= 9

DO
ext$(e) = ext$(e) + MID$(a$, cnt, 1)
cnt = cnt + 1
LOOP UNTIL cnt >= 13

f = f + 1
e = e + 1
END SUB

SUB refreshdir

CALL mirrordir

f = 1
e = 1
CALL listdir

CALL getdirname

KILL "dir.lst"

END SUB
