home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / dial.zip / dial.cmd < prev    next >
OS/2 REXX Batch file  |  1994-04-14  |  3KB  |  132 lines

  1. /* Telephone program
  2.    Written by Helge Hafting
  3.    email:
  4.    hafting@pvv.unit.no
  5.    snail mail:
  6.    poverudvn. 22
  7.    N-3440 R¢yken
  8.    NORWAY
  9. */
  10.  
  11. arg tlf
  12.  
  13. if (tlf='' | tlf='?') then signal hjelp
  14.  
  15. do while left(tlf,1) = ' '
  16.  tlf = substr(tlf,2)
  17. end 
  18.  
  19. silent = 0
  20. force = 0
  21. disp = 1
  22. num = 0
  23.  
  24. param = left(tlf,1)
  25. if param = '/' then do 
  26.  tlf = substr(tlf,2)
  27.  do while param <> ' '
  28.   param = left(tlf,1)
  29.   tlf = substr(tlf,2)
  30.   select
  31.    when param = 'S' then silent = 1
  32.    when param = 'F' then force = 1
  33.    when param = 'D' then disp = 0
  34.    when param = '#' then num = 1
  35.    when param = ' ' then nop
  36.   otherwise
  37.    say 'Unknown parameter: "' param '"'
  38.   end
  39.  end
  40. end 
  41. if (tlf='' | tlf='?') then signal hjelp
  42.  
  43. mmbase = value('MMBASE',,OS2ENVIRONMENT)
  44. if mmbase='' & \force & \silent then signal nixmmpm 
  45.  
  46. n=setlocal()
  47. parse source dummy1 dummy2 prg
  48. parse upper value prg with newdir '\DIAL.CMD'
  49. call directory(newdir)
  50.  
  51. if \silent then do
  52.  add_err = rxfuncadd("mciRxInit", "MCIAPI", "mciRxInit")
  53.  call mciRxInit
  54.  rc = mciRxSendString('open waveaudio alias lyd wait', 'RetStr', '0', '0')
  55.  if rc <> 0 then signal feil
  56. end 
  57.  
  58. add_err = rxfuncadd("SysSleep", "RexxUtil", "SysSleep")
  59. if add_err then say 'Warning: had trouble finding SysSleep in RexxUtil.  Pauses may be unavailable.'
  60.  
  61. forrige = '_'
  62. do while tlf <> ''
  63.  siffer = left(tlf,1)
  64.  dsp = siffer
  65.  tlf = substr(tlf,2)
  66.  type = pos(siffer,'ABCDEFGHIJKLMNOPRSTUVWXY123456789*0#,')
  67.  if type > 0 then do
  68.   if siffer = '*' then siffer='stjerne'
  69.   else if type < 25 then do
  70.    siffer = trunc((type + 5) / 3)
  71.    if num then dsp = siffer
  72.   end
  73.   if disp then call charout , dsp
  74.   if \silent then do
  75.    if siffer <> ',' then do
  76.     filnavn = siffer'.wav'
  77.     if siffer = forrige then rc = mciRxSendString('seek lyd to start wait', 'RetStr', '0', '0')
  78.     else rc = mciRxSendString('load lyd' filnavn 'wait', 'RetStr', '0', '0')
  79.     if rc <> 0 then signal feil
  80.     rc = mciRxSendString('play lyd wait', 'RetStr', '0', '0')
  81.     if rc <> 0 then signal feil
  82.    end 
  83.    else call SysSleep 1;
  84.   end
  85.  end
  86. end
  87.  
  88. if \silent then do
  89.  rc = mciRxSendString('close lyd wait', 'RetStr', '0', '0')
  90.  if rc <> 0 then signal feil
  91.  call mciRxExit
  92. end
  93.  
  94. call RxFuncDrop SysSleep
  95. exit(0)
  96.  
  97. feil:
  98. MacRC = mciRxGetErrorString(rc, 'ErrStVar')
  99. say 'error' rc',' ErrStVar
  100. rc = mciRxSendString('close lyd wait', 'RetStr', '0', '0')
  101. call mciRxExit
  102. call RxFuncDrop SysSleep
  103. exit(rc)
  104.  
  105. nixmmpm:
  106. say 'MMPM seems not present.  Try silent operation, or use force.'
  107. exit(1)
  108.  
  109. hjelp:
  110. say
  111. say 'Usage: dial [/parameters] <phone number>'
  112. say
  113. say 'Parameters, '
  114. say
  115. say 'S Silent       - don''t generate dialling tones.'
  116. say '                 Useful for converting letters to numbers.'
  117. say 'D no Display   - don''t display the numbers as they are dialled'
  118. say '# numbers only - show the number a letter is converted to,'
  119. say '                 instead of the letter itself.'
  120. say 'F Force        - forces operation when mmpm cannot be detected.'
  121. say
  122. say 'Commas "," in the number will cause 1 second pauses. '
  123. say 'Examples:'
  124. say
  125. say 'dial 1234567'
  126. say 'dial /#S (865) 9-ABC-567'
  127. say 'dial /D 12-345-76, *5,,, *2 ##4'
  128. say
  129. exit(0)
  130.  
  131.  
  132.