Each line of the file represents a single appointment. An appointment consists of two fields: a time and a description. One or more tabs must separate the two fields. Appointments may occur in any order, and times in a variety of convenient formats should be permitted.
The program, which we will call calendar, takes three command-line options. The first two of these are options that have no value after the option:
calendar -t <calfile display an ordered list of today's appointments calendar -n <calfile print the next appointmentFor example, suppose it is currently 2PM on April 26. Then the command:
calendar -t <calfilewould print:
Your appointments for 04/26/91: 12:00:00 lunch with Andy 15:00:00 group meetingwhile this command:
calendar -n <calfilewould print:
Your next appointment is on 04/26/91: 15:00:00 group meetingFinally, the -r option takes a regular expression which is used to limit consideration to those appointments the user is interested in. For example to determine when the next appointment with a family member will occur, the user can say:
calendar -n -r 'wife|brother|aunt|uncle' <calfilewhich would print:
Your next appointment is on 04/29/91: 14:00:00 visit Aunt EdnaThe remainder of this tutorial is devoted to implementing the electronic appointment calendar.