WORKSHOP\DRIVE.DOC  ·  DOC  ·  1.9 KB  ·  1991-01-01  ·  from PCPlus_Issue-52_Jan-1991_FluxEngine-360Kb
DRIVE    by Philema Perspectives

DRIVE is a little program that permits a user, for example, within a .BAT
file to determine whether there is a diskette in a particular drive (A or B),
whether it has been newly inserted, and whether it is write-enabled or not.

Syntax is as follows:
                DRIVE  d
                        where d is either A or B

DRIVE will set the ERRORLEVEL with one of the following values:
        0 indicates that there is a diskette currently in the drive,
          write is enabled, and the diskette has already been referenced
          (i.e. the gate has remained shut since the last I/O operation to
           the drive).
        1 indicates that there is a diskette currently in the drive, but
          but that it is write-protected.
        2 indicates that the gate had been opened since the previous I/O
          function for this drive: there is now a disk present, but no
          information is available (yet) about whether write is enabled.
          (To get that information, repeat DRIVE again).
      128 indicates that the drive has no diskette at present.
      129 indicates a serious I/O fault while attempting to read the
          diskette.
      255 indicates a parameter error.

Note that DRIVE is effective for ensuring that a backup disk, for example, has
been inserted: in the illustrative batch file from this month's Help Screen,
DRIVE could be inserted after the first PAUSE, to determine that a backup
diskette was indeed inserted, and had been write enabled.

Another illustrative .BAT file is enclosed here: A.BAT will enable more
sophisticated (and safe) switching to a diskette than A: (the drive letter
followed by a colon).  A.BAT will test that there is something present to
switch to, first: this will neatly avoid that horrible DOS message,
'Not ready error reading drive A  -  Abort, Retry, Fail?'