(view source code of cdrom.rex as plain text)
/* Display blank line */
say
/* Check for command line parameter (none required) */
parse arg params
if params <> "" then call Syntax
/* Initialize RexxUtil library */
if RxFuncAdd( 'sysloadfuncs', 'RexxUtil', 'sysloadfuncs' ) = 0 then do
call sysloadfuncs
end
else do
call Syntax "RexxUtil"
end
/* Retrieve list of local drives */
drives = SysDriveMap( "C:", "LOCAL" )
/* Check file system type of each drive */
do i = 1 by 1 until drives = ""
drive.0 = i
parse value drives with drive.name.i drives
drive.type.i = SysFileSystemType( drive.name.i )
end
/* Create arrays with CD-ROM drives and unknown drives */
cdrom.0 = 0
unknown.0 = 0
do i = 1 to drive.0
if drive.type.i = "CDFS" then do
j = cdrom.0 + 1
cdrom.j = drive.name.i
cdrom.0 = j
end
if drive.type.i = "" then do
j = unknown.0 + 1
unknown.j = drive.name.i
unknown.0 = j
end
end
/* Display results, showing unknown drives only if no CD-ROM drive was found */
if cdrom.0 = 0 then do
if unknown.0 = 0 then do
say "No CD-ROM drives found"
end
else do
unknowndrives = ""
do i = 1 to unknown.0
unknowndrives = unknowndrives||" "||unknown.i
end
say unknown.0||" unknown drive(s) found (possibly CD-ROM drive(s) without media): "||unknowndrives
end
end
else do
cdroms = ""
do i = 1 to cdrom.0
cdroms = cdroms||" "||cdrom.i
end
say cdrom.0||" CD-ROM drive(s) with media found: "||cdroms
end
/* Exit with number of CD-ROM drives found in return code */
EXIT cdrom.0
Syntax:
errcode = 0
parse arg errtype
if errtype = "RexxUtil" then do
errcode = 255
say "Error: RexxUtil could not be loaded"
say
end
say "CDROM.rex, Version 1.00"
say "Display CD-ROM drive letter(s) for the local computer"
say
say "Usage: <REXX> CDROM.rex"
say
say 'Where: "<REXX>" is your Rexx interpreter:'
say " - Windows: REGINA.EXE with RexxUtil installed"
say " (RexxUtil is not compatible with REXX.EXE)"
say " - OS/2: no need to specify, just rename script to *.cmd"
say
say "Returns: - Screen output with number of CD-ROM drives (with media)"
say " and drive letter(s) found"
say " - Return code is the number of drives (with media) found"
say " or 255 if RexxUtil could not be loaded"
say
say "Written by Rob van der Woude"
say "http://www.robvanderwoude.com"
EXIT errcode
return
page last modified: 2024-04-16; loaded in 0.0063 seconds