home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
basic
/
library
/
pb
/
library4
/
ttdir105.bas
< prev
next >
Wrap
BASIC Source File
|
1990-11-24
|
6KB
|
187 lines
$COMPILE UNIT
$INCLUDE "REGNAMES.INC"
'
' ┌─────────────────────────────────────────────────────────────────────┐
' │ │
' │ Function Name: GetDirectory │
' │ Date.........: 90/11/16 │
' │ │
' │ Description..: Reads the directory specified by the user and │
' │ returns an array of the files found. │
' │ │
' └─────────────────────────────────────────────────────────────────────┘
'
' Modified.....: 90/11/23
'
' 1.01 - Changed the return of the complete
' directory in FileFound$ to the filename,
' attribute, date and time to separate
' fields.
'
' 1.02 - Changed the calculation for the number of
' files. I did a direct calc outside the loop
' instead of incrementing a counter within
' the loop.
'
' 1.03 - Fixed the portion that calculated the file
' size. I used the wrong type of 'peek'
' function and the maximum size it returned
' was 65,535.
'
' 1.04 - Passed file string information in one
' string and date/time information in one
' array.
'
' 1.05 - Moved the DOS call to get the DTA address.
' The program only needs to find out the
' address once!
'
SUB GetDirectory(Path$, FileInfo$(), FIDate%(), FISize&(), NumFiles%) LOCAL PUBLIC
' The parameters for the sub-routine are as follows:
'
' Path$ - The file path
'
'
' FileInfo$(r,c) - The files found. A string array with up
' to 'r' number of elements with 'c'
' columns. Column 1 is the file name.
' Column 2 is the file extension and column
' 3 is the attributes of the file.
'
'
'
' FIDate%(r,c) - The Date and time for each file found. This
' is a two dimensional array. The number of
' rows ('r') must be the same as for the
' FileInfo$ field. The number of columns
' ('c') must be six (For Year, Month, Day,
' Hour, Minute, Second)
'
' FISize&(r) - The size in bytes of each file.
'
' NumFiles% - The number of files found in the directory
' specified by PATH$
'
'
LOCAL A%
LOCAL CDHiB%
LOCAL CDLowB%
LOCAL CDMidB%
LOCAL CTHiB%
LOCAL CTLowB%
LOCAL CTMidB%
LOCAL DTAAttr&
LOCAL DTADate&
LOCAL DTAOFS&
LOCAL DTASEG&
LOCAL DTASize&
LOCAL DTATime&
LOCAL FDate%
LOCAL FF$
LOCAL FTHour%
LOCAL FTime%
LOCAL LowB%
LOCAL UpprB%
'
' Get the lower and upper bound for all of the arrays used. I am assuming
' that all arrays are defined with the same lower and upper bound ranges.
'
LowB% = LBOUND(FileInfo$(1))
UpprB% = UBOUND(FileInfo$(1))
CDLowB% = LBOUND(FIDate%(2))
CDMidB% = CDLowB% + 1%
CDHiB% = CDLowB% + 2%
CTLowB% = CDLowB% + 3%
CTMidB% = CDMidB% + 3%
CTHiB% = CDHiB% + 3%
FF$ = DIR$(Path$, 55%)
'
' Make a call to get the DTA on the file just read in. I moved this code
' to outside the loop as I only have to get the address once!
'
REG %AX, &H2F00
CALL INTERRUPT &H21
DTASEG& = REG(%ES)
DTAOFS& = REG(%BX)
DTAAttr& = DTAOFS& + 21
DTASize& = DTAOFS& + 26
DTADate& = DTAOFS& + 24
DTATIME& = DTAOFS& + 22
DO WHILE (LEN(FF$) > 0% AND LowB% <= UpprB%)
DEF SEG = DTASEG&
A% = PEEK(DTAAttr&)
FISize&(LowB%) = PEEKL(DTASize&)
FDate% = PEEKI(DTADate&)
FTime% = PEEKI(DTATime&)
DEF SEG
FileInfo$(LowB%, 1) = FF$
FileInfo$(LowB%, 2) = " "
X% = INSTR(FF$, ".")
IF X% > 0 THEN
FileInfo$(LowB%, 1) = MID$(FF$, 1, X%-1)
FileInfo$(LowB%, 2) = MID$(FF$, X%+1)
END IF
FileInfo$(LowB%, 3%) = "....."
IF (A% AND 32%) THEN
MID$(FileInfo$(LowB%, 3%), 4, 1) = "A"
END IF
IF (A% AND 16%) THEN
MID$(FileInfo$(LowB%, 3%), 5, 1) = "D"
END IF
IF (A% AND 4%) THEN
MID$(FileInfo$(LowB%, 3%), 1, 1) = "S"
END IF
IF (A% AND 2%) THEN
MID$(FileInfo$(LowB%, 3%), 2, 1) = "H"
END IF
IF (A% AND 1%) THEN
MID$(FileInfo$(LowB%, 3%), 3, 1) = "R"
END IF
FIDate%(LowB%, CTLowB%) = FTime% \ 2048% ' Hours
IF FIDate%(LowB%, CTLowB%) < 0% THEN
INCR FIDate%(LowB%, CTLowB%), 31% ' Fix for some P.M. hours
END IF
FIDate%(LowB%, CTMidB%) = (FTime% AND 2047%) \ 32% ' Minutes
FIDate%(LowB%, CTHiB%) = FTime% AND 31% ' Seconds
FIDate%(LowB%, CDLowB%) = (FDate% \ 512%) + 80% ' Year
FIDate%(LowB%, CDMidB%) = (Fdate% AND 511%) \ 32% ' Month
FIDate%(LowB%, CDHiB%) = FDate% AND 31% ' Day
INCR LowB%, 1
'
' If not the last entry in the array read another directory entry.
'
IF LowB% <= UpprB% THEN
FF$ = DIR$
END IF
WEND
NumFiles% = LowB% - LBOUND(FileInfo$(1)) ' Calculate number of
' files found.
END SUB