home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / cmdpk164.zip / watchdrv.cmd < prev    next >
OS/2 REXX Batch file  |  1998-01-10  |  3KB  |  102 lines

  1. /* This is CommandPak's watchdrv command.               */
  2. /* (w) 1997-98 Ulrich Möller                            */
  3.  
  4. '@echo off'
  5.  
  6. call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  7. call SysLoadFuncs
  8. signal on error   /* When commands fail, call "error" routine. */
  9. signal on halt    /* When interrupted, call "halt" routine. */
  10. parse arg opt
  11.  
  12. do
  13.     drive = ""
  14.     play = 0
  15.     ignore = 0
  16.     interval = ""
  17.     insound = ""
  18.     outsound = ""
  19.     do while (opt \= "")
  20.         parse value opt with opt1 opt
  21.         /* Say "Parsing" opt1 */
  22.         select
  23.             when (length(opt1)=2) & (substr(opt1, 2, 1)=":") then do
  24.                 drive = translate(opt1)
  25.             end
  26.             when (substr(opt1, 1, 2)="-h") | (substr(opt1, 1, 2)="-?") then do
  27.                 'call xhelp watchdrv'
  28.                 exit
  29.             end
  30.             when (substr(opt1, 1, 3)="-t:") then interval = substr(opt1, 4)
  31.             when (substr(opt1, 1, 4)="-si:") then insound = substr(opt1, 5)
  32.             when (substr(opt1, 1, 4)="-so:") then outsound = substr(opt1, 5)
  33.             when (substr(opt1, 1, 2)="-i") then ignore = 1
  34.             when (substr(opt1, 1, 6)="--play") then do
  35.                 play = 1
  36.                 Say 'Sorry, the "play" function is not implemented yet.'
  37.                 exit
  38.                 rc = RXFUNCADD('mciRxInit','MCIAPI','mciRxInit')
  39.                 InitRC = mciRxInit()
  40.             end
  41.         otherwise do
  42.             'call xhelp -f invalidOptionMsg watchdrv'
  43.             exit
  44.         end
  45.         end /* select */
  46.     end
  47.     if (drive = "") then do
  48.         drives = SysDriveMap()
  49.         drive = word(drives, words(drives))
  50.         'call xhelp -f wdAssumeMsg' drive
  51.     end
  52.  
  53.     'call xhelp -f wdBeginMsg' drive
  54.  
  55.     if (interval="") then interval=2
  56.     'call xhelp -f wdFrequencyMsg' interval
  57.     'call xhelp -f wdMinimizeMsg' interval
  58.     if ignore then do
  59.         lastid = SysDriveInfo(drive)
  60.         if (lastid \= "") then Say "Current media:" lastid
  61.         else Say "Current media: none"
  62.     end
  63.     else lastid = ""
  64.     do forever
  65.         Call Charout ,"."
  66.         id = SysDriveInfo(drive)
  67.         if (id = "") & (play) then do
  68.             rc = mciRxSendString('open cdaudio alias cd shareable wait', 'RetStr', '0', '0')
  69.             rc = mciRxSendString('status cd media present wait', 'RetStr', '0', '0')
  70.             if (RetStr = "TRUE") then id = "audio cd"
  71.             rc = mciRxSendString('status cd mode wait', 'RetStr', '0', '0')
  72.             rc = mciRxSendString('close cd wait', 'RetStr', '0', '0')
  73.         end
  74.         if (lastid \= id) then do
  75.             if (id \= "") then do
  76.                 'call xhelp -f wdInsertMsg'
  77.                 Say id
  78.                 if (insound \= "") then 'call play file='||insound
  79.                 call SysOpenObject drive||"\","DEFAULT",1
  80.             end
  81.             else  do
  82.                 'call xhelp -f wdRemoveMsg'
  83.                 if (outsound \= "") then 'call play file='||outsound
  84.             end
  85.             lastid = id
  86.         end
  87.         call SysSleep interval
  88.     end
  89. end
  90. exit
  91.  
  92. error:
  93.     ErrRC = rc
  94.     say 'Fehler' ErrRC 'in Zeile' sigl ', Quellenzeile:' sourceline(sigl)
  95.     MacRC = mciRxExit()       /* Tell the DLL we're going away */
  96.     exit ErrRC                /* exit, tell caller things went poorly */
  97.  
  98. halt:
  99.     'call xhelp -f abortMsg watchdrv'
  100.     exit
  101.  
  102.