home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: Multimed / Multimed.zip / vclck02.zip / VoiceClock.cmd < prev    next >
OS/2 REXX Batch file  |  1996-08-26  |  8KB  |  252 lines

  1. /*************************************************************************/
  2. /* VoiceClock REXX Program v0.02   Chris Boyd                            */
  3. /*                                 email: cboyd@ksu.ksu.edu              */  
  4. /* ───────────────────────────────────────────────────────────────────── */
  5. /*  VoiceClock/REXX v0.02 by Chris Boyd  August 26, 1996  OS/2 freeware  */
  6. /* ───────────────────────────────────────────────────────────────────── */
  7. /*                                                                       */
  8. /* Ths REXX program will announce the TIME and DATE through a WAVEAUDIO  */
  9. /* device (such as a SoundBlaster audio card).                           */
  10. /*                                                                       */
  11. /* Type VOICECLOCK /? to see a list of options                           */
  12. /*                                                                       */
  13. /*************************************************************************/
  14.  
  15. signal on halt
  16.  
  17. call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  18. call SysLoadFuncs
  19.  
  20. a = 0
  21. b = 0
  22. c = 0
  23. d = 0
  24. e = 0 
  25. f = 0
  26. g = 0
  27. x = 0
  28. FirstWait  = 0
  29. SecondWait = 0
  30.  
  31. arg param1 param2 param3
  32.  
  33. /* Process command line parameters */
  34.  
  35. if param1 = '/?' then c = 1
  36. if param1 = '-?' then c = 1
  37. if param1 = '?' then c = 1
  38. if left(param1,2) = '/C' then do
  39.    a = 1
  40.    pp1 = length(param1)
  41.    if pp1 = 2 then x = 0
  42.    if pp1 <> 2 then x = right(param1,pp1-2)
  43.    if x = 'Q' then do
  44.       e = 1
  45.       g = 1
  46.       x = 0
  47.    end
  48.    if x = 0 then e = 1
  49. end
  50. if param1 = '/D' then b = 1
  51. if param1 = '/T' then b = 2
  52. if param1 = '/N' then d = 1
  53. if left(param2,2) = '/C' then do
  54.    a = 1
  55.    pp2 = length(param2)
  56.    if pp2 = 2 then x = 0
  57.    if pp2 <> 2 then x = right(param2,pp2-2)
  58.    if x = 'Q' then do
  59.       e = 1
  60.       g = 1
  61.       x = 0
  62.    end
  63.    if x = 0 then e = 1
  64. end
  65. if param2 = '/?' then c = 1
  66. if param2 = '-?' then c = 1
  67. if param2 = '?' then c = 1
  68. if param2 = '/D' then b = 1
  69. if param2 = '/T' then b = 2
  70. if param2 = '/N' then d = 1
  71. if param3 = '/?' then c = 1
  72. if param3 = '-?' then c = 1
  73. if param3 = '?' then c = 1
  74. if left(param3,2) = '/C' then do
  75.    a = 1
  76.    pp3 = length(param3)
  77.    if pp3 = 2 then x = 0
  78.    if pp3 <> 2 then x = right(param3,pp3-2)
  79.    if x = 'Q' then do
  80.       e = 1
  81.       g = 1
  82.       x = 0
  83.    end
  84.    if x = 0 then e = 1
  85. end
  86. if param3 = '/D' then b = 1
  87. if param3 = '/T' then b = 2
  88. if param3 = '/N' then d = 1
  89.  
  90. f=1
  91.  
  92. if c = 1 then do
  93.    say ''
  94.    say '────────────────────────────────────────────────────────────────────'
  95.    say 'VoiceClock/REXX v0.02 by Chris Boyd  August 26, 1996   OS/2 freeware'
  96.    say '────────────────────────────────────────────────────────────────────'
  97.    say ''
  98.    say '  Usage: VOICECLOCK (switches)'
  99.    say ''
  100.    say '  Switches:'
  101.    say ''
  102.    say '        /Cx = CONTINUOUS announce mode'
  103.    say '              x = minutes between announcements'
  104.    say '              x = 0 to announce on the half hour and hour'
  105.    say '              x = Q to announce on quarter, half hour, and hour'
  106.    say ''
  107.    say '        /T = Announce TIME only'      
  108.    say '        /D = Announce DATE only'      
  109.    say ''
  110.    say '        /N = Disables screen output  /? = Displays help screen'
  111.    say ''
  112.    exit
  113. end
  114.  
  115. if a = 0 then WhenAnnounce = '  ■ SINGLE announce mode'
  116. if a = 1 then WhenAnnounce = '  ■ CONTINUOUS announce mode'
  117. if a = 1 then do
  118.    if e = 0 then InteAnnounce = '  ■ Announce every ' x ' minute(s)'
  119.    if e = 1 then do
  120.       if g = 0 then InteAnnounce = '  ■ Announce on every half hour and hour'
  121.       if g = 1 then InteAnnounce = '  ■ Announce on every quarter, half hour, and hour'
  122.    end
  123. end
  124. if b = 1 then WhatAnnounce = '  ■ DATE only'
  125. if b = 2 then WhatAnnounce = '  ■ TIME only' 
  126.  
  127. if d = 0 then do
  128.    say ''
  129.    say '────────────────────────────────────────────────────────────────────'
  130.    say 'VoiceClock/REXX v0.02 by Chris Boyd  August 26, 1996   OS/2 freeware'
  131.    say '────────────────────────────────────────────────────────────────────'
  132.    say ''
  133.    say WhenAnnounce
  134.    if b <> 0 then say WhatAnnounce
  135.    if a = 1 then say InteAnnounce
  136.    say ''
  137.    if a = 1 then say 'Press CTRL-C to quit'
  138.    if a = 1 then say ''
  139. end
  140.  
  141. /* CONTINUOUS ANNOUNCE LOOP START (IF A = 1) */
  142. do until a = 0
  143.    
  144.    /* Parse the DATE and TIME */
  145.  
  146.    TodayMonth         = DATE('M')
  147.    TodayDaySpecific   = DATE('W')
  148.    TodayDayNumber     = DATE('E')
  149.    TodayDayNumber     = LEFT(TodayDayNumber,2)
  150.    NowHour            = TIME('H')
  151.    IF NowHour > 12 THEN NowHour = NowHour - 12
  152.    NowMinute          = TIME('N')
  153.    NowMinute = RIGHT(LEFT(NowMinute,5),2)
  154.    NowAP = RIGHT(TIME('C'),2)
  155.  
  156.    /* Calculate the filenames of WAV files */
  157.  
  158.    DayFilename = ('the'TodayDayNumber'.WAV')
  159.    DayArg = ('FILE='DayFilename)
  160.    MonthFilename = (TodayMonth'.WAV')
  161.    MonthArg = ('FILE='MonthFilename)
  162.    DaySFilename = (TodayDaySpecific'.WAV')
  163.    DaySArg = ('FILE='DaySFilename)
  164.    if NowHour = 0 then NowHour = 12
  165.    HourFilename = (NowHour'.WAV')
  166.    HourArg = ('FILE='HourFilename)
  167.    if NowHour < 10 then HourArg = ('FILE=0'HourFilename)
  168.    MinuteFilename = (NowMinute'.WAV')
  169.    if NowMinute < 10 then MinuteFilename = ('O'NowMinute'.WAV') 
  170.    MinuteArg = ('FILE='MinuteFilename)
  171.    APFilename = (NowAP'.WAV')
  172.    APArg = ('FILE='APFilename)
  173.  
  174.    /* ANNOUNCE THE TIME */
  175.  
  176.    if b <> 1 then do
  177.       call Play.cmd 'FILE=TheTimeIs.WAV'
  178.       call Play.cmd HourArg
  179.       if NowMinute <> 0 then do
  180.          call Play.cmd MinuteArg
  181.       end
  182.       call Play.cmd APArg
  183.    end
  184.  
  185.    /* ANNOUNCE THE DATE */
  186.    if b <> 2 then do
  187.       call Play.cmd 'FILE=TodayDate.WAV'
  188.       call Play.cmd DaySArg
  189.       call Play.cmd MonthArg
  190.       call Play.cmd DayArg
  191.    end 
  192.  
  193.    /* IF CONTINUOUS MODE, SLEEP FOR SPECIFIED INTERVALS */
  194.  
  195.    if a = 1 then do
  196.       if f = 1 then do
  197.          NowMinute     = TIME('N')
  198.          NowMinute     = RIGHT(LEFT(NowMinute,5),2)
  199.          NowSeconds    = RIGHT(TIME('N'),2)
  200.          TotalSeconds  = (NowMinute*60)+NowSeconds
  201.          if NowSeconds <> 0 then FirstWait=(((x-1)*60)+(60-NowSeconds))
  202.          if e = 1 then do 
  203.             if NowMinute < 30 then FirstWait = (1800-TotalSeconds)
  204.             if NowMinute > 30 then FirstWait = (3600-TotalSeconds)
  205.             if NowMinute = 30 then FirstWait = (1800-NowSeconds)
  206.             if NowMinute = 0  then FirstWait = (1800-NowSeconds)
  207.             if g = 1 then do
  208.                FirstWait = (3600-TotalSeconds)
  209.                if NowMinute = 45 then FirstWait = (900-NowSeconds)
  210.                if NowMinute < 45 then FirstWait = (2700-TotalSeconds)
  211.                if NowMinute = 30 then FirstWait = (900-NowSeconds)
  212.                if NowMinute < 30 then FirstWait = (1800-TotalSeconds)
  213.                if NowMinute = 15 then FirstWait = (900-NowSeconds)
  214.                if NowMinute < 15 then FirstWait = (900-TotalSeconds)
  215.                if NowMinute =  0 then FirstWait  = (900-NowSeconds)
  216.             end
  217.          end
  218.       end
  219.       if f = 0 then do
  220.          SecondWait = (x*60)
  221.          NowMinute     = TIME('N')
  222.          NowMinute     = RIGHT(LEFT(NowMinute,5),2)
  223.          NowSeconds    = RIGHT(TIME('N'),2)
  224.          TotalSeconds  = (NowMinute*60)+NowSeconds
  225.          if NowSeconds <> 0 then SecondWait = (((x-1)*60)+(60-NowSeconds))
  226.          if e = 1 then do 
  227.             if NowMinute < 30 then SecondWait = (1800-TotalSeconds)
  228.             if NowMinute > 30 then SecondWait = (3600-TotalSeconds)
  229.             if NowMinute = 30 then SecondWait = (1800-NowSeconds)
  230.             if NowMinute = 0  then SecondWait = (1800-NowSeconds)
  231.             if g = 1 then do
  232.                SecondWait = (3600-TotalSeconds)
  233.                if NowMinute = 45 then SecondWait = (900-NowSeconds)
  234.                if NowMinute < 45 then SecondWait = (2700-TotalSeconds)
  235.                if NowMinute = 30 then SecondWait = (900-NowSeconds)
  236.                if NowMinute < 30 then SecondWait = (1800-TotalSeconds)
  237.                if NowMinute = 15 then SecondWait = (900-NowSeconds)
  238.                if NowMinute < 15 then SecondWait = (900-TotalSeconds)
  239.                if NowMinute =  0 then SecondWait  = (900-NowSeconds)
  240.            end
  241.          end
  242.       end
  243.    if f = 1 then call SysSleep FirstWait
  244.    if f = 0 then call SysSleep SecondWait
  245.    f = 0
  246.    end
  247. end
  248.  
  249. halt:
  250.  
  251.  
  252.