Board index » delphi » Check floppy drive for disc

Check floppy drive for disc

How do I write a  short program to check a floppy drive for a disc and
return an instruction to the user to input a floppy disc. I f no disk
is in the drive.

 

Re:Check floppy drive for disc


Quote
> How do I write a  short program to check a floppy drive for a disc and
> return an instruction to the user to input a floppy disc. I f no disk
> is in the drive.

   The following should help:

[ Isdisk.pas < 1K ]
function ValidDrive (D : word): boolean;{ determines if Drive has disk }
var Regs : Registers;
begin
  with Regs do
    begin
      AX := $1C00; DX := D;
      MsDos (REGS);
      ValidDrive := AL <> $FF
    end;  { with }
end;  { ValidDrive }

procedure IsDisk (DR : integer);      { verify disk in drive }
var S : string;
begin
  GetDir (DR,S);                         { get name of drive }
  while not ValidDrive (DR) do
    begin
      gotoXY (1,25);
      writeln(' Disk is NOT PRESENT in drive '+S[1]+' - please CORRECT ',^7);
      Delay (1000)
    end;
  gotoXY (1,25); ClrEol
end;  { IsDisk }

  IsDisk (1); { wait until disk in drive A }

Other Threads