home *** CD-ROM | disk | FTP | other *** search
/ PC Plus 53 / ISSUE_53_FEB_1991 / PCPLUS / WORKSHOP / WORKSHOP.EXE / GETDRIVE.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1990-11-18  |  942 b   |  36 lines

  1. Program GetDrive;
  2.  
  3.                            { ** Program that detects current logged Drive
  4.                                 then reports it as an Errorlevel to DOS   **}
  5.  
  6. Var Current_Dir : String[40];
  7.  
  8.  
  9. Procedure Syntax;
  10.  
  11. Begin
  12.   Writeln;
  13.   Writeln('GETDRIVE returns an Errorlevel to DOS depending on the current');
  14.   Writeln('logged Drive: A: --> 0  B: --> 1  C: --> 2  D: --> 3 etc., etc.');
  15.   Writeln;
  16.   Writeln('The correct Syntax is      GETDRIVE');
  17.   Writeln;
  18.   Writeln('NOTE: If an Error in detecting the Drive occurs');
  19.   Writeln('then an Errorlevel of 100 will be returned to DOS');
  20.   Writeln;
  21.   Writeln('(c) Barrie Edwards 1990');
  22.   Writeln;
  23.   Halt(100)
  24. End;
  25.  
  26.  
  27. Begin
  28.   IF ParamCount > 0 then Syntax;           {Explain use of GetDrive}
  29.   {$I-}
  30.   GetDir(0, Current_Dir);
  31.   {SI+}
  32.   If IOResult <> 0 then Halt(100) else    {Cannot Read the Disk - report error}
  33.   Halt(Ord(Current_Dir[1])-65)
  34. End.
  35.  
  36.