# alarm --- sleep for specified interval, display clock, then beep define (SECS_PER_DAY,86400) integer i, j, clock integer ctoi, parstm, equal, equis, getarg longint value, now, then longint time_of_day, curtime, goal integer hrs, min, sec character arg (MAXARG) i = 1 if (getarg (i, arg, MAXARG) == EOF) value = 0 else if (equal (arg, "at"s) == YES) { i += 1 j = 1 if (getarg (i, arg, MAXARG) == EOF || parstm (arg, j, then) == ERR) call usage now = time_of_day (now) value = then - now if (value < 0) value += SECS_PER_DAY } else { if (equal (arg, "in"s) == YES) { i += 1 if (getarg (i, arg, MAXARG) == EOF) call usage } j = 1 value = intl (ctoi (arg, j)) if (j == 1) call usage select when (arg (j) ~= EOS) ; when (getarg (i + 1, arg, MAXARG) ~= EOF) { i += 1 j = 1 } ifany select when (equis (arg (j), "seconds"s) ~= NO) ; when (equis (arg (j), "minutes"s) ~= NO) value *= 60 when (equis (arg (j), "hours"s) ~= NO) value *= 3600 else call usage } if (getarg (i + 1, arg, 1) ~= EOF) call usage call break$ (DISABLE) # disable break key curtime = time_of_day (value) goal = curtime + value if (goal >= SECS_PER_DAY) goal -= SECS_PER_DAY hrs = goal / 3600 min = mod ((goal / 60), 60) sec = goal - hrs * 3600 - min * 60 call print (ERROUT, "Alarm set for *2,,0i:*2,,0i:*2,,0i*n"s, hrs, min, sec) call print (ERROUT, " Current time "s) call clock (value) call break$ (ENABLE) stop end # usage --- print usage diagnostic and die subroutine usage call error ("Usage: alarm ([in] [] | at