BBS: Inland Empire Archive Date: 12-19-92 (22:26) Number: 363 From: ROB MCKEE Refer#: NONE To: STEVE PERRY Recvd: NO Subj: Re: FCB's Conf: (2) Quik_Bas
'Hi Steve,
'SP> This is probably a dumb question, but here it goes. I need to get the
'SP> size of a file. I'm currently doing a shell command and directing it to
'SP> a file that I open and then search for the needed data. I was looking
'SP> through a interrupts book and it shows that interrupt 21h with ah = 23h
'SP> and ds:dx = pointer to an unopened file control block. Can this be done
'SP> in PDS? If so how? How do you access a FCB anyway?
'SP> Any and all help would be appreciated!
This should do it for you.
' $DYNAMIC
TYPE RegType
ax AS INTEGER
Bx AS INTEGER
cx AS INTEGER
dx AS INTEGER
bp AS INTEGER
si AS INTEGER
di AS INTEGER
Flags AS INTEGER
END TYPE
TYPE RegTypeX
ax AS INTEGER
Bx AS INTEGER
cx AS INTEGER
dx AS INTEGER
bp AS INTEGER
si AS INTEGER
di AS INTEGER
Flags AS INTEGER
ds AS INTEGER
Es AS INTEGER
END TYPE
TYPE FileDataType
Flname AS STRING * 12
Year AS INTEGER
Month AS INTEGER
Day AS INTEGER
Hour AS INTEGER
moniute AS INTEGER
Second AS INTEGER
Attribute AS INTEGER
Size AS LONG
END TYPE
DIM RegX AS RegTypeX
DECLARE SUB FindFirstFile (Path$, Attrib%, DTA$, Result%)
DECLARE SUB FindNext (Attrib%, DTA$, Result%)
SUB FindFirstFile (Path$, Attrib%, DTA$, Result%) STATIC
DIM RegX AS RegTypeX
thPath$ = Path$ + CHR$(0)
RegX.ax = &H2F00
CALL interrupt(&H21, RegX, RegX)
sgmnt% = RegX.Es
offst% = RegX.Bx
DTA$ = SPACE$(43)
' set the DTA
RegX.ax = &H1A00
RegX.ds = VARSEG(DTA$)
RegX.dx = SADD(Dat$)
CALL interruptX(&H21, RegX, RegX)
' find first file
RegX.ax = &H4E00
RegX.cx = Attrib%
RegX.ds = VARSEG(thePath$)
RegX.dx = SADD(thePath$)
CALL interruptX(&H21, RegX, RegX)
Result% = RegX.Flags AND 1
' reset the DTA
RegX.ax = &H1A00
RegX.ds = sgmnt%
RegX.dx = offst%
CALL interruptX(&H21, RegX, RegX)
END SUB
REM $STATIC
SUB FindNext (Attrib%, DTA$, Result%) STATIC
DIM RegX AS RegTypeX
IF LEN(DTA$) <> 43 THEN
Result% = 2 ' Exit errorcode of 2
EXIT SUB
END IF
RegX.ax = &H2F00
CALL interrupt(&H21, RegX, RegX)
sgmnt% = RegX.Es
offst% = RegX.Bx
DTA$ = SPACE$(43)
' set the DTA
RegX.ax = &H1A00
RegX.ds = VARSEG(DTA$)
RegX.dx = SADD(Dat$)
CALL interruptX(&H21, RegX, RegX)
' find first file
RegX.ax = &H4F00
RegX.cx = Attrib%
RegX.ds = VARSEG(thePath$)
RegX.dx = SADD(thePath$)
CALL interruptX(&H21, RegX, RegX)
Result% = RegX.Flags AND 1
' reset the DTA
RegX.ax = &H1A00
RegX.ds = sgmnt%
RegX.dx = offst%
CALL interruptX(&H21, RegX, RegX)
END SUB
SUB GetFileData (DTA$, File AS FileDataType) STATIC
File.Attribute = ASC(MID$(DTA$, 22, 1))
Tim& = CVI(MID$(DTA$, 23, 2))
IF Tim& < 0 THEN Tim& = Tim& + 65536
File.Second = Tim& AND &H1F
File.Minute = (Tim& \ 32) AND &H3F
File.Hour = (Tim& \ 2048) AND &H1F
Dat& = CVI(MID$(DTA$, 25, 2))
IF Dat& < 0 THEN Dat& = Dat& + 65536
File.Day = Dat& AND &H1F
File.Month = (Dat& \ 32) AND &HF
File.Year = ((Dat& \ 512) AND &H1F) + 1980
File.Size = CVL(MID$(DTA$, 27, 4))
f$ = MID$(DTA$, 31) + CHR$(0)
File.Flname = LEFT$(f$, INSTR(f$, CHR$(0)) - 1)
END SUB
TTYL -Rob
--- EZPoint V2.2
* Origin: Flyer Proof Computer Services (1:125/1212.13)

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