Re: Suppress Critical Error Message

new topic     » goto parent     » topic index » view thread      » older message » newer message

A function to read the number of available bytes on a disk:

-- CODE BEGINS HERE
-- dskspace.e

include machine.e

global function dskspace(integer drive_num)
-- return number of available bytes on disk
-- return 0 if disk not recognized
-- drive_num 0 is the default, a is 1, etc ...
sequence reg_list
    -- initialize the registers
    reg_list = repeat(0, 10)
    reg_list[REG_DX] = drive_num
    -- call DOS function 36H
    reg_list[REG_AX] = #3600
    -- do the interrupt 21H call
    reg_list = dos_interrupt(#21, reg_list)
   -- returns available clusters in BX,
   -- bytes per cluster in CX,
    -- and sectors per cluster in AX
    -- Note: total number of bytes on the disk =
    -- DX * CX * AX
    return reg_list[REG_BX] * reg_list[REG_CX] * reg_list[REG_AX]
end function    -- dskspace

----------------------------------------------------------------
-- usage:

printf(1, "your a disk has %d bytes available.\n", dskspace(1))

-- CODE ENDS HERE

cheers,

Ad Rienks.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu