$CPU 8086 ' make compatible with XT systems $LIB ALL OFF ' turn off all PowerBASIC libraries $ERROR ALL OFF ' turn off all PowerBASIC error checking $OPTIMIZE SIZE ' optimize for smaller code $COMPILE UNIT ' compile to a UNIT (.PBU) '$COMPILE EXE ' compile to a UNIT (.PBU) DEFINT A-Z ' Required for all numeric functions, forces PB to not ' include floating point in UNIT (makes it smaller) '/*------------------------------------------------------------------*/ $CODE SEG "MLIB4" '/*------------------------------------------------------------------*/ ' DiskFree - Return the amount of free bytes on the specified drive; if the ' drive is invalid then assume the current logged drive ' ' Drive = Drive letter to return amount of free space. A null string ' will return the default drive. ' FUNCTION GETDRIVEFREE(BYVAL Drive AS STRING) PUBLIC AS DWORD DIM DriveNum AS INTEGER DriveNum = ASCII(UCASE$(Drive)) - 64 IF DriveNum < 0 THEN DriveNum = 0 END IF ! push DS ; save DS PowerBASIC ! mov AX, &H3600 ; function 36h, get drive info ! mov DX, DriveNum ; put requested drive in DX ! int &H21 ; call DOS ! cmp AX, &HFFFF ; does AX = -1? ! je DiskFreeDone ; yes, there was an error ! mul CX ; AX = AX * CX ! mul BX ; AX = AX * BX ! mov FUNCTION[0], AX ; return low part of dword ! mov FUNCTION[2], DX ; return high part of dword DiskFreeDone: ! pop DS ; restore DS for PowerBASIC END FUNCTION '/*------------------------------------------------------------------*/ ' CLS ' T# = DRIVEFREE("C") ' PRINT T# ' INPUT Z