home *** CD-ROM | disk | FTP | other *** search
/ HomeWare 14 / HOMEWARE14.bin / prog / fdate80a.arj / ALARM.BAT next >
DOS Batch File  |  1993-07-20  |  6KB  |  181 lines

  1. @echo off
  2.  
  3. goto endcomment
  4. REVISION HISTORY
  5. ----------------
  6.  
  7. :endcomment
  8.  
  9. BREAK ON
  10. cls
  11. echo ╔═════════════════════════════════════════════════════════════════════════════╗
  12. echo ║                              ALARM                                          ║
  13. echo ║ Function: Wait until a certain time, then sound an alarm.                   ║
  14. echo ║           Press CTL+BREAK to exit.                                          ║
  15. echo ╚═════════════════════════════════════════════════════════════════════════════╝
  16.  
  17. if not (%1)==() goto start
  18. rem color is white on blue
  19. echo ╔═════════════════════════════════════════════════════════════════════════════╗
  20. echo ║ USAGE   : ALARM                      shows current time in hhmm format      ║
  21. echo ║ USAGE   : ALARM hhmm [msg]           waits until hhmm, then sounds an alarm ║
  22. echo ║                                                                             ║
  23. echo ║ EXAMPLE : ALARM 0930                 [sounds alarm at 9:30 am]              ║
  24. echo ║ EXAMPLE : ALARM 930 Staff meeting    [sounds alarm at 9:30 am]              ║
  25. echo ║ EXAMPLE : ALARM 1800                 [sounds alarm at 6:00 pm]              ║
  26. echo ║                                                                             ║
  27. echo ║           For midnight, specify 0000 or 2400 for hhmm.                      ║
  28. echo ║ EXAMPLE : ALARM 2400  START MIDNIGHT BATCH RUN                              ║
  29. echo ║                                                                             ║
  30. echo ║ Note:  Because this batch file does a LOT of disk activity,                 ║
  31. echo ║        it is STRONGLY recommended that you make your current                ║
  32. echo ║        directory a RAM disk before running it.                              ║
  33. echo ║                                                                             ║
  34. echo ║        To prevent repeated disk accesses to find the FDATE program,         ║
  35. echo ║        you should also have FDATE on the RAM disk, or be using a cache.     ║
  36. echo ╚═════════════════════════════════════════════════════════════════════════════╝
  37. fdate /Ff /Ohh:mm:ss /P"Time is now: "
  38. goto endit
  39.  
  40. :start
  41.  
  42. rem If RAMDISK is specified, change to RAM disk.  This will eliminate
  43. rem the tremendous amount of disk accesses this batch file does.
  44. rem ----------------------------------------------------------------
  45. IF NOT "%RAMDISK%"=="" %RAMDISK%:
  46.  
  47. set alarm=%1
  48. shift
  49.  
  50. rem get time now numeric representation
  51. fdate /Ff /Ohhmm /P"@set timenow=" >junktemp.bat
  52. call junktemp.bat
  53. del  junktemp.bat
  54.  
  55. rem do a numeric compare: alarm time to 2400
  56. fdate /f#comp /A%alarm% /B2400 /P"@set comp=" >junktemp.bat
  57. call junktemp.bat
  58. del  junktemp.bat
  59.  
  60. if (%comp%)==(ERROR) goto endit
  61.  
  62. if (%comp%)==(LT) goto OKtime
  63.  
  64. if (%comp%)==(EQ) set alarm=0000
  65. if (%comp%)==(EQ) goto OKtime
  66.  
  67. echo ALARM REQUEST REJECTED.  ALARM TIME [%alarm%] IS GREATER THAN 2400.
  68. goto endit
  69.  
  70. :OKtime
  71.  
  72. rem do a numeric compare: alarm time to timenow
  73. fdate /f#comp /A%alarm% /B%timenow% /P"@set comp=" >junktemp.bat
  74. call junktemp.bat
  75. del  junktemp.bat
  76.  
  77. if (%comp%)==(EQ) echo ALARM REQUEST REJECTED.  ALARM TIME [%alarm%] AND TIME NOW ARE THE SAME.
  78. if (%comp%)==(EQ) goto endit
  79.  
  80. rem  display time that alarm was set
  81. fdate /Ff
  82. fdate /Ff /Ohh:mm:ss /P"Alarm wait started at "
  83.  
  84. if (%comp%)==(GT) goto latertoday
  85.  
  86. rem else: fall through to tomorrow ...
  87.  
  88. :tomorrow
  89.  
  90. rem get the date that the alarm was set, i.e. today's date
  91. fdate /Ff /Omm-dd-ccyy /P"@set setdate=" >junktemp.bat
  92. call junktemp.bat
  93. del  junktemp.bat
  94.  
  95. ECHO.
  96. ECHO WAITING UNTIL MIDNIGHT (TOMORROW, 0000 HOURS) BEFORE STARTING MAIN WAIT.
  97. ECHO.
  98. ECHO WAITING UNTIL: %alarm%
  99. ECHO MESSAGE:
  100. ECHO    %1 %2 %3 %4 %5 %6 %7 %8 %9
  101.  
  102. rem loop until tomorrow
  103. :top1
  104.    rem ---- WHILE condition ----------------------------------------
  105.    rem compare today's date to setdate
  106.    fdate /Fcomp /At /B%setdate% /P"@set comp=" >junktemp.bat
  107.    call junktemp.bat
  108.    del  junktemp.bat
  109.  
  110.    if (%comp%)==(GT) goto end1
  111.  
  112.    rem ---- loopbody -----------------------------------------------
  113.    fdate /Ff /Ohh:mm:ss /P"Current time : "
  114.    echo A
  115.  
  116.    goto top1
  117. :end1
  118.  
  119. ECHO.
  120. ECHO MIDNIGHT ...
  121.  
  122.  
  123. rem -------------------------------------------------------------
  124. :latertoday
  125. ECHO.
  126. ECHO WAITING UNTIL: %alarm%
  127. ECHO MESSAGE:
  128. ECHO    %1 %2 %3 %4 %5 %6 %7 %8 %9
  129.  
  130. :top2
  131.    rem ---- WHILE condition ----------------------------------------
  132.    rem get time now numeric representation
  133.    fdate /Ff /Ohhmm /P"@set timenow=" >junktemp.bat
  134.    call junktemp.bat
  135.    del  junktemp.bat
  136.  
  137.    rem do a numeric compare: alarm time to timenow
  138.    fdate /f#comp /A%timenow% /B%alarm% /P"@set comp=" >junktemp.bat
  139.    call junktemp.bat
  140.    del  junktemp.bat
  141.  
  142.    if (%comp%)==(GT) goto end2
  143.    if (%comp%)==(EQ) goto end2
  144.  
  145.    rem ---- loopbody -----------------------------------------------
  146.    fdate /Ff /Ohh:mm:ss /P"Current time : "
  147.    echo A
  148.  
  149.    goto top2
  150. :end2
  151.  
  152.  
  153. rem -------------------------------------------------------------
  154. :alarm
  155.  
  156. REM The time that was to be waited for has arrived.
  157. REM Sound alarm bell and display message.
  158.  
  159. :top3
  160. cls
  161. BREAK OFF
  162. fdate /Ff /Ot1 /P"@set timenow=" >junktemp.bat
  163. call junktemp.bat
  164. del  junktemp.bat
  165.  
  166. rem color is white on red
  167. echo 
  168.  
  169. echo ╔══════════════════════════════════════════╗
  170. FOR %%V IN (x x x x x x x x) do echo ║  It is %timenow%    Press ^BREAK to exit.  ║
  171. echo ╚══════════════════════════════════════════╝
  172.  
  173. BREAK ON
  174. FOR %%V IN (x x x x x x x x) do echo      %1 %2 %3 %4 %5 %6 %7 %8 %9   
  175.  
  176. rem sound beeps. CONTROL-G is BEEP.
  177. echo                           
  178. GOTO top3
  179.  
  180. :endit
  181.