REXX Tips & Tricks, Version 2.80


Inf-HTML [About][Toc][Index] 0.9b (c) 1995 Peter Childs


Check if a drive is ready





 
/* sample code to test if a drive is ready                            */
/* note:     This routine does not work under Object-Oriented REXX    */
/*           if the line AUTOFAIL=NO is missing in the CONFIG.SYS     */
/*                                                                    */
/*           [Tested with OBJREXX 6.00 12 Jul 1996]             v2.60 */
/*           [Fixed in OBJREXX 6.00 26 Feb 1997 and newer versions (included in WARP 4 Fixpack #6)]        v2.60 */

  do forever
    call lineOut , "Enter the name of the drive to test " ,
                   "(RETURN to end): "
    thisDrive = strip( lineIn() )
    if thisDrive = "" then
      leave

    if DriveReady( thisDrive ) = 1 then
      say "The drive <" || thisDrive || "> is ready."
    else
      say "The drive <" || thisDrive || "> is not ready."
  end /* do forever */

exit 0

/* ------------------------------------------------------------------ */
/* function: Check if a drive is ready                                */
/*                                                                    */
/* call:     DriveReady( testDrive )                                  */
/*                                                                    */
/* where:    testdrive - Name of the drive to test (e.g. "A:")        */
/*                                                                    */
/* returns:  1 - drive is ready                                       */
/*           0 - drive is not ready                                   */
/*                                                                    */
/* note:     This routine does not work under Object-Oriented REXX    */
/*           if the line AUTOFAIL=NO is missing in the CONFIG.SYS     */
/*                                                                    */
/*           [Tested with OBJREXX 6.00 12 Jul 1996]             v2.60 */
/*           [Fixed in OBJREXX 6.00 26 Feb 1997 and newer versions (included in WARP 4 Fixpack #6)]        v2.60 */
DriveReady: PROCEDURE
  parse arg driveToTest ":" .

  thisRC = 0

                        /* install a temporary error handler to check */
                        /* if the drive is ready                      */
  SIGNAL ON NOTREADY Name DriveReadyEnd

  call stream driveToTest || ":\*", "D"
  thisRC = 1

DriveReadyEnd:
  RETURN thisRC

  

Inf-HTML End Run - Successful