This is a cut-down version of "findfile.bas" (from the PB FTP area). Findfile finds certain files and lists size, etc etc and is
All I want to do is list all files (and subdirs and subfiles) in any specified directory, so ive made a cut-down version called "listfile.bas".
It behaves strangely though and I can't see why?
Or, does anyone have any working PBDOS source that simply lists all files in a specified directory?
Thankyou muchly!
------------------
All I want to do is list all files (and subdirs and subfiles) in any specified directory, so ive made a cut-down version called "listfile.bas".
It behaves strangely though and I can't see why?
Code:
$CPU 8086 ' program works on any CPU $COMPILE EXE ' compile to an EXE $ERROR ALL OFF ' turn off error handling $STRING 8 ' set largest string size at 8k $STACK 16384 ' use a 16k stack $OPTION CNTLBREAK OFF ' don't allow Ctrl-Break to exit program $INCLUDE "PB35.INC" ' link library DEFINT A-Z ' default all variables to integers for maximum ' speed and minimum size EXIT FAR AT FarExit 'to exit all recursion StartPath$ = "c:\temp" 'get the default drive FileSpec$ = "*.*" 'get the search filespec ListFiles StartPath$, FileSpec$ 'do the search FarExit: 'for EXIT FAR END SUB ListFiles(StartPath AS STRING, FileSpec AS STRING) PRIVATE DIM OldDtaBuffer AS STRING DIM DtaSeg AS INTEGER DIM DtaOfs AS INTEGER DIM CurrPath AS STRING DIM Tmp AS INTEGER GetDTA DtaSeg, DtaOfs DEF SEG = DtaSeg OldDtaBuffer = PEEK$(DtaOfs, 44) 'save current DTA information DEF SEG STDOUT StartPath$ FileName$ = DIR$(StartPath$ + "*.*", 55) WHILE LEN(FileName$) > 0 STDOUT "FILE=" & StartPath$ & FileName$ IF (DtaAttrib = 16) AND (ASCII(FileName$) <> 46) THEN ListFiles StartPath$ + FileName$ + "\", FileSpec$ ELSEIF WildMatchFile(FileName$,FileSpec$) THEN END IF IF INKEY$ = CHR$(27) THEN 'is escape is pressed EXIT FAR END IF FileName$ = DIR$ ' find next WEND DEF SEG = DtaSeg POKE$ DtaOfs, OldDtaBuffer$ 'restore saved DTA information DEF SEG END SUB
Thankyou muchly!
------------------
Comment