/* NotifyNoise 1.02 */
/* Copyright  Michael Tanzer, 1991, 1992 */
/* See additional notices in accompanying documentation */

twentyfour = 0                /* 0 = 12-hour noise; 1 = 24-hour noise */

/* Build time table */
t.0  = 'twelve'
t.1  = 'one'
t.2  = 'two'
t.3  = 'three'
t.4  = 'four'
t.5  = 'five'
t.6  = 'six'
t.7  = 'seven'
t.8  = 'eight'
t.9  = 'nine'
t.10 = 'ten'
t.11 = 'elevven'
t.12 = 'twelve'
t.13 = 'thir teen'
t.14 = 'four teen'
t.15 = 'fif teen'
t.16 = 'six teen'
t.17 = 'seven teen'
t.18 = 'ay teen'
t.19 = 'nine teen'
t.20 = 'twenty'
t.30 = 'thirty'
t.40 = 'forty'
t.50 = 'fifty'

parse arg time message
parse var time hh':'mm
if ~datatype(hh,'W') | ~datatype(mm,'W') then call error
if hh<0 | hh>23 then call error
if mm<0 | mm>59 then call error

/* Get hour */
if twentyfour then do
  hh = hh+0
  select
    when hh=0 then hour = 'zeerow'
    when hh<10 then hour = 'o' t.hh
    when hh<21 then hour = t.hh
    otherwise interpret 'hour = ''twenty'' t.'substr(hh,2)
    end
  end
else interpret 'hour = t.'hh//12

/* Get minute */
mm = mm+0
select
  when mm=0 then do
    if twentyfour then minute = 'hundredh'
    else minute = 'owclock'
    end
  when mm<10 then do
    if twentyfour then minute = 'o' t.mm
    else minute = t.mm
    end
  when mm<21 then minute = t.mm
  otherwise do
    interpret 'minute = t.'substr(mm,1,1)'0'
    w = substr(mm,2)
    if w>0 then interpret 'minute = minute t.'w
    end
  end

/* Make some noise */
text = '"it is now' hour',' minute'.' translate(message,' ','\')'"'
address command 'sys:utilities/say' text
exit

/* Handle invalid time */
error:
  address command 'sys:utilities/say invalid time specified.'
  exit
