Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for driverdy.cmd

(view source code of driverdy.cmd as plain text)

  1. /* DRIVEReaDY,  Version 1.00       */
  2. /* Check if drive is ready         */
  3. /* Written by Rob van der Woude    */
  4. /* Needs Quercus System's RexxLib  */
  5.  
  6. /* Initialize RexxLib if necessary */
  7. if RxFuncQuery( "RexxLibRegister" ) <> 0 then do
  8. 	call RxFuncAdd "RexxLibRegister", "RexxLib", "RexxLibRegister"
  9. 	call RexxLibRegister
  10. end
  11.  
  12. /* Check command line parameter */
  13. parse upper arg drive dummy
  14. if dummy <> "" then call Syntax
  15. drive = strip( drive )
  16. drvlen = length( drive )
  17. select
  18. 	when drvlen > 2 then call Syntax
  19. 	when drvlen = 2 then do
  20. 		if right( drive, 1 ) <> ":" then call Syntax
  21. 		drvletter = left( drive, 1 )
  22. 		if drvletter < "A" | drvletter > "Z" then call Syntax
  23. 	end
  24. 	when drvlen = 1 then do
  25. 		drive = drive||":"
  26. 		if drvletter < "A" | drvletter > "Z" then call Syntax
  27. 	end
  28. 	otherwise call Syntax
  29. end
  30.  
  31. /* Check if specified drive is ready */
  32. if dosdisk( "T", drive ) = -1 then do
  33. 	say "Drive "||drive||" is not ready"
  34. 	rc = 1
  35. end
  36. else do
  37. 	say "Drive "||drive||" is ready"
  38. 	rc = 0
  39. end
  40.  
  41. /* End of main program, exit with return code */
  42. exit rc
  43.  
  44.  
  45. Syntax:
  46. 	say
  47. 	say "DRIVEReaDY,  Version 1.00 for OS/2"
  48. 	say
  49. 	say "Usage   :   DRIVERDY  d:"
  50. 	say
  51. 	say "            d: may be any drive from A: to Z:"
  52. 	say
  53. 	say "Returns :   returncode 0 if ready, otherwise 1"
  54. 	exit 255
  55. return
  56.  

page last uploaded: 2016-12-15, 11:20