BBS: Inland Empire Archive Date: 03-27-93 (15:04) Number: 370 From: TOM HAMMOND Refer#: NONE To: MICHAEL BAILEY Recvd: NO Subj: File Date/Time 2/2 Conf: (2) Quik_Bas
>>> Continued from previous message
Well, I owe you one for your 'OpenComm' routine. Very slick. This routine
will get the file date, time, and size using CALL Interrupt. You can always
cut out what you don't need.
- - - - - - - - - - - - - - - - - cut here - - - - - - - - - - - - - - - -
'$INCLUDE: 'QB.BI'
TYPE DOSFindType '| The DTA structure for the DOS
Reserved AS STRING * 21 '| FindFirst/FindNext functions
DFileAttr AS STRING * 1
DosTime AS INTEGER
DosDate AS INTEGER
FileSize AS LONG
FileName AS STRING * 13
END TYPE
DIM DOSFindBuff AS DOSFindType
DIM Regs AS RegTypeX '| Register TYPE for Interrupt call
DIM FindFileBuff AS STRING * 64 '| Buffer to hold file path
SearchFile$ = "\autoexec.bat" '| Example file to look for
Regs.ax = &H2F00 '| Get the old DTA address
CALL INTERRUPTX(&H21, Regs, Regs)
OldDTASeg% = Regs.es '| Save it to restore later
OldDTAOff% = Regs.bx
Regs.ax = &H1A00 '| Set our filefind buffer as
Regs.ds = VARSEG(DOSFindBuff) '| the new DTA
Regs.dx = VARPTR(DOSFindBuff)
CALL INTERRUPTX(&H21, Regs, Regs)
FindFileBuff = SearchFile$ + CHR$(0)'| Load our current filename
Regs.ax = &H4E00 '| into the FileName buffer
Regs.cx = 7 '| Attribute for normal, hidden,
'| R/O, and system files
Regs.ds = VARSEG(FindFileBuff)
Regs.dx = VARPTR(FindFileBuff)
CALL INTERRUPTX(&H21, Regs, Regs) '| Call the DOS findfirst func.
IF (Regs.flags AND 1) THEN '| Carry flag was set, no
PRINT "File Not Found" '| files by this name
ELSE '| Pull the info out
Hour% = (DOSFindBuff.DosTime AND &H7800) \ 2048
'| Adjust for sign ext. if needed
IF (DOSFindBuff.DosTime AND &H8000) THEN
Hour% = Hour% + 16
END IF
SFileTime$ = LTRIM$(STR$(Hour%)) '| Start output string
Min% = (DOSFindBuff.DosTime AND &H7E0) \ 32
Min$ = LTRIM$(STR$(Min%))
IF (LEN(Min$) = 1) THEN '| Format value for output string
SFileTime$ = SFileTime$ + ":0" + Min$
ELSE
SFileTime$ = SFileTime$ + ":" + Min$
END IF
Secs% = (DOSFindBuff.DosTime AND &H1F) * 2
Secs$ = LTRIM$(STR$(Secs%))
IF (LEN(Secs$) = 1) THEN
SFileTime$ = SFileTime$ + ":0" + Secs$
ELSE
SFileTime$ = SFileTime$ + ":" + Secs$
END IF
Year% = (DOSFindBuff.DosDate AND &H7E00) \ 512
IF (DOSFindBuff.DosDate% AND &H8000) THEN
Year% = Year% + 2044
ELSE
Year% = Year% + 1980
END IF
Mon% = (DOSFindBuff.DosDate AND &H1D0) \ 32
Day% = (DOSFindBuff.DosDate AND &H1F)
SFileDate$ = LTRIM$(STR$(Mon%)) + "/" + LTRIM$(STR$(Day%)) + _
"/" + RIGHT$(LTRIM$(STR$(Year%)), 2)
SFileSize& = DOSFindBuff.FileSize
PRINT SearchFile$ + " " + SFileDate$ + " " + SFileTime$ + _
" "; SFileSize&
END IF
Regs.ax = &H1A00 '| Restore the original DTA
Regs.ds = OldDTASeg%
Regs.dx = OldDTAOff%
CALL INTERRUPTX(&H21, Regs, Regs)
END
- - - - - - - - - - - - - - - - - cut here - - - - - - - - - - - - - - -
Saving and restoring the DTA is not strictly necessary in a stand-alone
program like this, but doing it will let you stick the code in a sub without
worrying about it. Lines with an underscore as the last character should
have the following line appended to them.
---
* Origin: Night Shift BBS (314)635-7588 HST 14.4 (1:289/15)

Books at Amazon:
Back to BASIC: The History, Corruption, and Future of the Language
Hackers: Heroes of the Computer Revolution (including Tiny BASIC)
Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution
The Advent of the Algorithm: The Idea that Rules the World
Moths in the Machine: The Power and Perils of Programming
Mastering Visual Basic .NET