vbdpss.hlp (Table of Contents; 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.
Article Q46980, Example
                                                 Contents  Index  Back
─────────────────────────────────────────────────────────────────────────────
                           Knowledge Base Contents  Knowledge Base Index
 
 CALL INTERRUPT Example to Get Disk Drive Capacity, Free Space - Q46980
 
 Code Sample
 -----------
 
 You can compile this program within the QuickBasic environment as
 follows:
 
    QB filename /L [ QB.QLB ]
 
 For Basic PDS versions 7.0 and 7.1, start the QBX.EXE environment as
 follows:
 
    QBX filename /L [ QBX.QLB]
 
 Or, compile with BC.EXE and LINK.EXE as follows:
 
    BC filename [ options ]
    LINK filename,,,QB.LIB [ options ]
 
 For Basic PDS versions 7.0 and 7.1, use BC.EXE and LINK.EXE as follows:
 
    BC filename [ options ]
    LINK filename,,,QBX.LIB [ options ]
 
 DECLARE FUNCTION unsignedlong& (num%)
 REM ******************************************************************
 REM **                                                              **
 REM ** RegType is a user-defined type used by the CALL INTERRUPT    **
 REM ** routine. The file QB.BI contains the user-defined type and   **
 REM ** the prototyping for the subprogram INTERRUPT. The            **
 REM ** INTERRUPT routine is located in the QB.QLB and the QB.LIB.  **
 REM **                                                              **
 REM ** For Basic PDS 7.0 use QBX.BI for the include file and the    **
 REM ** library QBX.QLB or QBX.LIB for CALL INTERRUPT support.      **
 REM **                                                              **
 REM ** Note: When not using the user-defined type provided with     **
 REM **       the QuickBasic package, the length of the TYPE must    **
 REM **       be 20 bytes long. Unpredictable results will occur     **
 REM **       if the length is less than 20 bytes.                  **
 REM **                                                              **
 REM ******************************************************************
 
 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
   DS    AS INTEGER
   ES    AS INTEGER
 END TYPE
 DIM REGS AS RegType
 CLS
 PRINT "**  Drive Capacity Utility  **": PRINT
 PRINT "NOTE: Drive number ranges 0 through 26, where A = 1, C = 3"
 PRINT
 INPUT "Drive number to obtain drive capacity from : ", DriveNum%
 IF DriveNum% < 0 OR DriveNum% > 26 THEN
    PRINT
    PRINT "ERROR: Invalid Drive Number (RANGE: 0 thru 26)"
    PRINT
    END
 END IF
 REGS.AX = &H3600      ' ** AH = 36, AL = 00
 REGS.DX = DriveNum%   ' ** DH = ??, DL = DriveNum%
 CALL INTERRUPT(&H21, REGS, REGS)
 IF REGS.AX = -1 THEN    ' ** -1 = &HFFFF
    PRINT
    PRINT "ERROR: Invalid Drive Specification"
    PRINT
    END
 END IF
 
 REM ** Convert the signed register values to "unsigned" long integer
 REM    values. This ensures that the amount of free disk space will be
 REM    a positive unsigned value.
 
 BXLong& = unsignedlong&(REGS.BX)
 CXLong& = unsignedlong&(REGS.CX)
 DXLong& = unsignedlong&(REGS.DX)
 
 REM ** TEMP = [ Sectors per cluster ] TIMES [ Bytes per Sector ]    **
 Temp& = REGS.AX * CXLong&
 
 REM ** CAPACITY  = [ TEMP ] TIMES [ Clusters per Drive ]            **
 Capacity& = Temp& * DXLong&
 
 REM ** AVAILABLE = [ TEMP ] TIMES [ Number of Available Clusters ]  **
 Available& = Temp& * BXLong&
 
 REM ** INUSE     = [ CAPACITY ] MINUS [ AVAILABLE ]                 **
 InUse& = Capacity& - Available&
 
 PRINT
 PRINT "Drive Number = "; DriveNum%
 IF DriveNum% = 0 THEN
    PRINT "** Default drive number used **"
 ELSE
    PRINT "      Letter =  "; CHR$(64 + DriveNum%)
 END IF
 PRINT
 PRINT USING "Capacity  = ###,###,###"; Capacity&
 PRINT USING "In Use    = ###,###,###"; InUse&
 PRINT "            ==========="
 PRINT USING "Available = ###,###,###"; Available&
 END
 
 FUNCTION unsignedlong& (num%)
        IF num% < 0 THEN
                unsignedlong& = num% + 65536
        ELSE
                unsignedlong& = num%
        END IF
 END FUNCTION