bas7ex.hlp (Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
Interrupt, InterruptX Routines Programming Example
                       Example                 Contents  Index  Back
──────────────────────────────────────────────────────────────────────────────
'This example uses the Interrupt routine to determine the current
'drive and the amount of free space remaining on the drive.
 
'Note: To use the Interrupt routine, you must load the Quick library
'QBX.QLB using the /L switch when you begin QBX. The following include
'file must also be present.
 
'$INCLUDE: 'QBX.BI'
 
'Define registers.
DIM regs AS RegType
 
'Get current drive info; set up input and do system call.
regs.ax = &H1900
CALL Interrupt(&H21, regs, regs)
 
'Convert drive info to readable form.
Drive$ = CHR$((regs.ax AND &HFF) + 65) + ":"
 
'Get disk free space; set up input values and do system call.
regs.ax = &H3600
regs.dx = ASC(UCASE$(Drive$)) - 64
CALL Interrupt(&H21, regs, regs)
 
'Decipher the results.
SectorsInCluster = regs.ax
BytesInSector = regs.cx
IF regs.dx >= 0 THEN
        ClustersInDrive = regs.dx
ELSE
        ClustersInDrive = regs.dx + 65536
END IF
IF regs.bx >= 0 THEN
        ClustersAvailable = regs.bx
ELSE
        ClustersAvailable = regx.bx + 65536
END IF
Freespace = ClustersAvailable * SectorsInCluster * BytesInSector
 
'Report results.
CLS
PRINT "Drive "; Drive$; " has a total of";
PRINT USING "###,###,###"; Freespace;
PRINT " bytes remaining free."