home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Black Box 4
/
BlackBox.cdr
/
progc
/
c_all592.arj
/
TI415.ASC
< prev
next >
Wrap
Text File
|
1991-08-27
|
2KB
|
133 lines
PRODUCT : TURBO BASIC NUMBER : 415
VERSION : 1.1
OS : DOS
DATE : December 30, 1987 Page 1/2
TITLE : Free Space on a Disk
This program demonstrates how to obtain the number of available bytes on a
disk using the REG and CALL INTERRUPT statements.
SUB GetFreeSpace(Drive)
SHARED Sectors,TotalSpace,AvailableSpace
' Load the AH register with 36 hex
REG 1,&H3600 ' The AL register contains 00
' Load the DX register with the drive designator
REG 4,Drive ' 0 = default, 1 = A, etc
Call Interrupt &H21 ' Invoke function 36 hex
Sectors = REG(1) ' sectors-per-allocation unit (cluster)
FreeAloc = REG(2) ' number of available clusters
BytesPerSector = REG(3) ' bytes per sector
TotalAloc = REG(4) ' total number of clusters
' calculate the total space on the drive
TotalSpace = TotalAloc*Sectors*BytesPerSector
' calculate the available space on the drive
AvailableSpace = FreeAloc*Sectors*BytesPerSector
END SUB
Start:
CLS
INPUT "Which Drive (<ENTER> for current):",Ans$
Ans$ = UCASE$(LEFT$(Ans$,1))
IF Ans$ = "" THEN
Drive = 0
ELSE
Drive = ASC(Ans$) - &H40
END IF
Call GetFreeSpace(Drive)
IF Sectors = -1 THEN 'SECTORS = -1 INDICATES AN
PRINT "Invalid Drive" 'INVALID DRIVE
DELAY 2
GOTO Start
END IF
PRODUCT : TURBO BASIC NUMBER : 415
VERSION : 1.1
OS : DOS
DATE : December 30, 1987 Page 1/2
TITLE : Free Space on a Disk
PRINT "Total size of the disk is ";TotalSpace;"bytes"
PRINT "Free area on disk is ";AvailableSpace;"bytes"
END