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 ( 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