Category : Miscellaneous Language Source Code
Archive   : QTAWKU42.ZIP
Filename : APPTDIS.EXP

 
Output of file : APPTDIS.EXP contained in archive : QTAWKU42.ZIP
# QTAwk utility to set alarm clock for next appointment time
# appointments stored in file "appoint.fle" in format:
#
# mm/dd/yy hh:mm appointment comments/description/place
# or
# mm/dd/yyyy hh:mm appointment comments/description/place
#
# the file "appoint.fle" is read until an appointment if found for today
# 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 {
stderr = "stderr";
if ( ARGC > 1 ) {
fprintf(stderr,"Incorrect Invocation.\nUsage: QTAwk -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

greg_jul = FALSE;
split(t1date,tdate,/\//);
today_jdn = jdn(tdate[3],tdate[1],tdate[2]);

# special date
special_date = "08/31/1996";
split(special_date,spldate,/\//);
spl_date_jdn = jdn(spldate[3],spldate[1],spldate[2]);
days_rem = spl_date_jdn - today_jdn;
spl_day = (spl_date_jdn + 1) % 7;
last_week = spl_day ? 1 : 0;

# 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 = /\//;

split(t0date,cdate,slash_s);
ARGV[ARGC++] = "c:\\appt" ï cdate[3] ï ".dat";

split(stime(2),now,colon_s);

hour = 1;
minute = 2;

appt_set = FALSE; # appointment set flag

notice_hr = 00; # set time for notices == 00:00

l1_hdr = ".======== " ï t1date ï " ========.";
l2_hdr = ".==================.";
spl_hdr = "*> " ï t1date ï " <> " ï special_date ï " <";
print l1_hdr;
print "Appointments: " ï t0date;
print " Time\tPurpose";
print ".---.\t.----------->";

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_list[lunch_time] = "Lunch Time";
}

if ( now[hour] < cob[hour] ||
(now[hour] == cob[hour] && now[minute] < cob[minute]) ) {
appt_list[cob_time] = "Closing Time";
}
}

# 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, apt_time;

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_time = $2;
$1 = $2 = "";
appt_list[appt_time] = strim($0,TRUE,FALSE);
appt_set = TRUE;
}
}
next;
}

{
if ( appt_set ) exit;
}

END {
for ( appt_time in notice ) printf("NOTICE\t%s\n",notice[appt_time]);
for ( appt_time in appt_list ) printf("%s\t%s\n",appt_time,appt_list[appt_time]);
# print l1_hdr;
print spl_hdr;
remg = "\tRemaining";
print "*\tDays: " ï days_rem ï remg;
print "*\tWeeks: " ï ((days_rem - spl_day)/7 + last_week) ï remg;
print "*\tMonths: " ï days_rem/30 ï remg;
print spl_hdr;
}

# function to convert year/month/day into julian day number
function jdn(year,month,day) {
local yr;
local pfac = 0.6;
local ljdn;

yr = year + (month - 3.0) / 12.0;
ljdn = int(367.0 * yr + pfac) - (2 * int(yr)) + int(yr/4.0)
+ int(day) + 1721117;
if ( !greg_jul ) ljdn += -int(yr/100.0) + int(yr/400.0) + 2;
return ljdn;
}


  3 Responses to “Category : Miscellaneous Language Source Code
Archive   : QTAWKU42.ZIP
Filename : APPTDIS.EXP

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/