Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for cdrom.rex

(view source code of cdrom.rex as plain text)

  1. /* Display blank line */
  2. say
  3.  
  4. /* Check for command line parameter (none required) */
  5. parse arg params
  6. if params <> "" then call Syntax
  7.  
  8. /* Initialize RexxUtil library */
  9. if RxFuncAdd( 'sysloadfuncs', 'RexxUtil', 'sysloadfuncs' ) = 0 then do
  10. 	call sysloadfuncs
  11. end
  12. else do
  13. 	call Syntax "RexxUtil"
  14. end
  15.  
  16. /* Retrieve list of local drives */
  17. drives = SysDriveMap( "C:", "LOCAL" )
  18.  
  19. /* Check file system type of each drive */
  20. do i = 1 by 1 until drives = ""
  21. 	drive.0 = i
  22. 	parse value drives with drive.name.i drives
  23. 	drive.type.i = SysFileSystemType( drive.name.i )
  24. end
  25.  
  26. /* Create arrays with CD-ROM drives and unknown drives */
  27. cdrom.0   = 0
  28. unknown.0 = 0
  29. do i = 1 to drive.0
  30. 	if drive.type.i = "CDFS" then do
  31. 		j       = cdrom.0 + 1
  32. 		cdrom.j = drive.name.i
  33. 		cdrom.0 = j
  34. 	end
  35. 	if drive.type.i = "" then do
  36. 		j         = unknown.0 + 1
  37. 		unknown.j = drive.name.i
  38. 		unknown.0 = j
  39. 	end
  40. end
  41.  
  42. /* Display results, showing unknown drives only if no CD-ROM drive was found */
  43. if cdrom.0 = 0 then do
  44. 	if unknown.0 = 0 then do
  45. 		say "No CD-ROM drives found"
  46. 	end
  47. 	else do
  48. 		unknowndrives = ""
  49. 		do i = 1 to unknown.0
  50. 			unknowndrives = unknowndrives||" "||unknown.i
  51. 		end
  52. 		say unknown.0||" unknown drive(s) found (possibly CD-ROM drive(s) without media): "||unknowndrives
  53. 	end
  54. end
  55. else do
  56. 	cdroms = ""
  57. 	do i = 1 to cdrom.0
  58. 		cdroms = cdroms||" "||cdrom.i
  59. 	end
  60. 	say cdrom.0||" CD-ROM drive(s) with media found: "||cdroms
  61. end
  62.  
  63. /* Exit with number of CD-ROM drives found in return code */
  64. EXIT cdrom.0
  65.  
  66.  
  67. Syntax:
  68. 	errcode = 0
  69. 	parse arg errtype
  70. 	if errtype = "RexxUtil" then do
  71. 		errcode = 255
  72. 		say "Error: RexxUtil could not be loaded"
  73. 		say
  74. 	end
  75. 	say "CDROM.rex,  Version 1.00"
  76. 	say "Display CD-ROM drive letter(s) for the local computer"
  77. 	say
  78. 	say "Usage:    <REXX>  CDROM.rex"
  79. 	say
  80. 	say 'Where:    "<REXX>" is your Rexx interpreter:'
  81. 	say "                   - Windows:  REGINA.EXE with RexxUtil installed"
  82. 	say "                               (RexxUtil is not compatible with REXX.EXE)"
  83. 	say "                   - OS/2:     no need to specify, just rename script to *.cmd"
  84. 	say
  85. 	say "Returns:  - Screen output with number of CD-ROM drives (with media)"
  86. 	say "            and drive letter(s) found"
  87. 	say "          - Return code is the number of drives (with media) found"
  88. 	say "            or 255 if RexxUtil could not be loaded"
  89. 	say
  90. 	say "Written by Rob van der Woude"
  91. 	say "http://www.robvanderwoude.com"
  92. 	EXIT errcode
  93. return
  94.  

page last modified: 2024-04-16; loaded in 0.0063 seconds