home *** CD-ROM | disk | FTP | other *** search
- $COMPILE UNIT
- $INCLUDE "REGNAMES.INC"
-
- '
- ' ┌─────────────────────────────────────────────────────────────────────┐
- ' │ │
- ' │ Function Name: GetDir │
- ' │ Date.........: 90/11/16 │
- ' │ │
- ' │ Description..: Reads the directory specified by the user and │
- ' │ returns an array of the files found. │
- ' │ │
- ' └─────────────────────────────────────────────────────────────────────┘
- '
- ' Original Code. Kept to illustrate the difference between the first 'draft'
- ' of the code and the current version.
- '
- SUB GetDir100(Path$, FilesFound$(), NumFiles%) LOCAL PUBLIC
-
- LOCAL A%
- LOCAL Att$
- LOCAL DTAOFS&
- LOCAL DTASEG&
- LOCAL FD$
- LOCAL FDate%
- LOCAL FSize&
- LOCAL FT$
- LOCAL FTHour%
- LOCAL FTime%
- LOCAL LowB%
- LOCAL UFn2$
- LOCAL UpprB%
- LOCAL X%
-
-
- '
- ' Get the lower bound and upper bound of the array for the directory.
- '
-
- LowB% = LBOUND(FilesFound$(1))
- UpprB% = UBOUND(FilesFound$(1))
-
- NumFiles% = 0
-
- FilesFound$(LowB%) = DIR$(Path$,55)
-
- DO WHILE (LEN(FilesFound$(LowB%)) > 0 AND LowB% <= UpprB%)
- INCR NumFiles%, 1
-
- '
- ' Make a call to get the DTA on the file just read in.
- '
- REG %AX, &H2F00
- CALL INTERRUPT &H21
-
- DTASEG& = REG(%ES)
- DTAOFS& = REG(%BX)
-
- DEF SEG = DTASEG&
- A% = PEEK(DTAOFS&+21) ' Attributes
- FSize& = (PEEK(DTAOFS&+27) * 256) + PEEK(DTAOFS&+26) ' Size
- FDate% = PEEKI(DTAOFS&+24) ' Date
- FTime% = PEEKI(DTAOFS&+22) ' Time
- DEF SEG
-
- '
- ' Convert the number into a string: Location 1 = System
- ' 2 = Hidden
- ' 3 = Read only
- ' 4 = Archive
- ' 5 = Directory Entry
- ' 6 = Blank for padding
-
- Att$ = "..... "
- IF (A% AND 32%) THEN
- MID$(Att$, 4, 1) = "A"
- END IF
-
- IF (A% AND 16%) THEN
- MID$(Att$, 5, 1) = "D"
- END IF
-
- IF (A% AND 4%) THEN
- MID$(Att$, 1, 1) = "S"
- END IF
-
- IF (A% AND 2%) THEN
- MID$(Att$, 2, 1) = "H"
- END IF
-
- IF (A% AND 1%) THEN
- MID$(Att$, 3, 1) = "R"
- END IF
-
- '
- ' Reformat the file name into a string 13 characters in length. Separate the
- ' file name from the extension. The file name is the right hand most portion
- ' of the string. The extension is the left most portion of the string. The
- ' 13th character is a blank for padding.
- '
-
- UFn2$ = SPACE$(13)
- IF (FilesFound$(LowB%) = ".") OR (FilesFound$(LowB%) = "..") THEN
- MID$(UFn2$, 1, LEN(FilesFound$(LowB%))) = FilesFound$(LowB%)
- ELSE
- X% = INSTR(FilesFound$(LowB%), ".")
- IF X% > 0 THEN
- MID$(UFn2$, 1, LEN(MID$(FilesFound$(LowB%), 1, X%-1))) = MID$(FilesFound$(LowB%), 1, X%-1)
- MID$(UFn2$, 10, LEN(MID$(FilesFound$(LowB%), X%+1))) = MID$(FilesFound$(LowB%), X%+1)
- ELSE
- MID$(UFn2$, 1, LEN(FilesFound$(LowB%))) = FilesFound$(LowB%)
- END IF
- END IF
-
- '
- ' Convert the File time into a string.
- '
- FTHour% = FTime% \ 2048%
- IF FTHour% < 0 THEN
- INCR FTHour%, 32% ' Fix for some P.M. hours
- END IF
-
- FT$ = USING$("##", FTHour%) + ":" + USING$("##", (FTime% AND 2047%) \ 32%) + ":" + USING$("##", FTime% AND 31%)
- REPLACE ANY " " WITH "0" IN FT$
-
- '
- ' Convert the file date into a string.
- '
-
- FD$ = USING$("##", (FDate% \ 512) + 80%) + "/" + USING$("##", (FDate% AND 511%) \ 32%) + "/" + USING$("##", FDate% AND 31%)
- REPLACE ANY " " WITH "0" IN FD$
-
- FilesFound$(LowB%) = UFn2$ + Att$ + USING$("######## ", FSize&) + FT$ + " "+ FD$
-
- INCR LowB%, 1
-
- '
- ' If not the last entry in the array read another directory entry.
- '
-
- IF LowB% <= UpprB% THEN
- FilesFound$(LowB%) = DIR$
- END IF
- WEND
-
- END SUB
-