home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
qtawk
/
alarm.exp
< prev
next >
Wrap
Text File
|
1990-07-25
|
4KB
|
122 lines
# QTAwk utility to set alarm clock for next appointment time appointments
# stored in file "apptXX.dat" (XX == current year) in format:
#
# mm/dd/yy hh:mm appointment comments/description/place
# or
# mm/dd/yyyy hh:mm appointment comments/description/place
#
# the file "apptXX.dat" is read finding all appointments for today. The
# appointments are stored in the array "appt_list" indexed by appointment time.
# Indexing by time automatically sorts the the appointsments by time in
# "appt_list". Once the file has been completely read, array "appt_list" is
# scanned for an appointment for which the appointment hour is equal to the
# current hour and the appointment minute is greater than the current minute or
# the appointment hour is greater than the current hour. An informative message
# is issued about the time set for the appointment, and the program to set the
# alarm is invoked. Any appointment comments are displayed
#
# Times are military times ( 0 <= hh < 24 )
#
BEGIN {
if ( ARGC > 1 ) {
fprintf("stderr","Incorrect Invocation.\nUsage: Awkplus -ftclk.exp\n");
exit;
}
# the following date formats would be used for U.S. style dates
t0date = sdate(0); # todays date: mm/dd/yy
t1date = sdate(1); # todays date: mm/dd/yyyy
# use following to allow more variation in date format
today = /^{_w}*({t0date}|{t1date}){_w}/;
# the following date formats would be used for European style dates
# t2date = sdate(2); # todays date: dd/mm/yy
# t3date = sdate(3); # todays date: dd/mm/yyyy
# use following to allow more variation in date format
# today = /^{_w}*({t2date}|{t3date}){_w}/;
time_pattern = /^[0-9]?[0-9]:[0-9][0-9]?$/;
colon_s = /:/;
slash_s = /\//;
hour = 1;
minute = 2;
appt_set = FALSE; # appointment set flag
set_appt = FALSE; # appointment set flag
appt_hdr = t0date ∩ " ==> Set Alarm time to: ";
appt_trl = "\nAppointment: ";
not_hdr = t0date ∩ " ==> NOTICE: ";
notice_hr = 00; # set time for notices == 00:00
split(t0date,cdate,slash_s);
ARGV[ARGC++] = "c:\\appt" ∩ cdate[3] ∩ ".dat";
split(stime(2),now,colon_s);
lunch_time = "11:30"; # lunch
split(lunch_time,lunch,colon_s);
cob_time = "16:05"; # close of business
split(cob_time,cob,colon_s);
if ( now[hour] < lunch[hour] ||
(now[hour] == lunch[hour] && now[minute] < lunch[minute]) ) {
appt = lunch;
appt_list[lunch_time] = "Lunch Time";
set_appt = TRUE;
}
if ( now[hour] < cob[hour] ||
(now[hour] == cob[hour] && now[minute] < cob[minute]) ) {
appt = cob;
appt_list[cob_time] = "Closing Time";
set_appt = TRUE;
}
}
# find only those lines with todays date to set appointments
# use following to allow more variation in date format
today { # find records for today
local atime, ai;
if ( $2 ~~ time_pattern ) {
split($2,atime,colon_s);
if ( atime[hour] == notice_hr &&
atime[minute] == 0 ) {
$1 = $2 = "";
notice[n_cnt++] = strim($0,TRUE,FALSE);
appt_set = TRUE;
} else if ( atime[hour] > now[hour] ||
(atime[hour] == now[hour] && atime[minute] > now[minute]) ) {
appt = atime;
appt_time = $2;
$1 = $2 = "";
appt_list[appt_time] = strim($0,TRUE,FALSE);
appt_set = TRUE;
}
}
next;
}
{
if ( appt_set ) exit;
}
END { # set lunch or close of business time if no other alarm set
# and current time is before lunch or close of business
print ".=======================.";
if ( set_appt || appt_set ) {
for ( appt_time in notice ) print not_hdr ∩ notice[appt_time];
for ( appt_time in appt_list ) {
system("alarm /S" ∩ appt_time); # invoke program to set alarm
print appt_hdr ∩ appt_time ∩ appt_trl ∩ appt_list[appt_time] ∩ "\nAppointment Set.";
break; # break off after setting first alarm
}
} else print "Past Closing Time";
print ".=======================.";
}