NAME

    pew, pew.format, whosmissing -- The church attendance package.

SYNOPSIS

    pew [filename] 

    pew.format [-ya] [filename]

    whosmissing [n]

DESCRIPTION

These programs are designed to assist an attendance clerk for a church 
keep track of who's been at church each Sunday. The programs are used to
maintain and search an attendance database. One of the programs works
sort of like an editor, but one which knows about the data base
residing under it.

The program 'pew' is the editor itself. If no data base file name is given,
it defaults to a file the name of which is the current year, eg., 1987.

The program 'pew.format' formats attendance information for printing.
It writes results to stdout, and defaults to reading data from stdin.
Normally it formats only the most recent 3 whole months and the results
will fit on an 80 column printer. Specifying -y causes the whole year
to be formated, and the results should be sent to a wide (130 column) 
printer. The database has a "printable" flag for each entry, and normally
entries will be printed or not depending upon this flag. Specifying
-a causes pew.format to format all entries.

The program 'whosmissing' will scan the current year's database for anyone 
who has missed church the previous n Sundays, where n defaults to 4. The 
output of whosmissing can be piped to pew.format for formatting.


THE DATA BASE:

While understanding the construction of the attendance database is not 
necessary for the use of these programs, it is included here in case one
desires to edit the database using a text editor such as vi(1).

The attendance data is held in an ordinary text file, with one text record
corresponding to one logical database record (for the most part, anyway). 
In general use, there is a database record for each family, and if anyone
(including children at home) is present, the family is marked as having
attended.

Each record contains at most 81 characters.  

The first character of each record (which is not directly viewable using the 
pew editor) determines the "printability" of this record:

	Blank:	Record is printable. Most records are this way.

	Non-blank:Record will not normally be printed. This is used for
		families that, say, visited once or twice a long time ago
		and we don't expect to see them again. 

The second character of each record defines what type of record it is:

	Blank or newline: This is a comment. It can be the title of a
		section (eg., "   MEMBERS"), or an extension of the name
		field for a data record (say, for children's names, e.g., 
		" Tom, Jenny"). These records contain up to 79 characters of 
		arbitrary data after the blank.

	Non-blank: This is a data record. It consists of a 27 character name
		field followed immediately by up to 53 columns of attendance
		data. Each column represents a week, with the column immediately
		after the name field representing the first Sunday in the year.
		While the content of the columns is arbitrary, the program
		currently places either an X (present) or a blank (absent)
		in a given column.

		Note that if 27 characters is insufficient for holding a name,
		additional information may be placed in a comment line
		immediately after the data record.


Typically, attendance lists are kept alphabetized (there is assistance in
the program for adding new names in the right place), and possibly in several
groups. For example, one might keep the data as follows:

		MEMBERS:

	Doe, John and Mary
	...
	Xavier, Caroline

		FRIENDS:

	Marshall, Frank
	...
	Wilson, Mark and Donna

		VISITORS:

	Murphy, Jim and Barbie
	...
	Peters, Cindy

Note the use of comment lines to break up the lists. These comments also
serve as section headings for printouts of the database.


pew EDITOR OPERATION

The pew editor knows about two different dates, called the "mark date" and
the "default date." The default date is the date of the most recent Sunday, 
while the mark date is anything the user might set. The mark date is so named
because the column representing this date is the one that will be "marked" when
the user presses the "mark" special function key in order to register 
attendance.  During some operations of the program, and at power up, the mark 
date is reset to be the same as the default date.

The pew editor has two different modes, called "left" and "right." The mode is 
toggled between left and right by pressing the TAB key.  Generally, in left 
mode the name field can be modified, and the only attendance that can be 
indicated is that of the default date. In right mode, the name field cannot 
be modified, but the mark date can be set to anything desired, thus allowing 
corrections to past attendance information.

When running the pew program, the display will show up to 21 lines of the
data base, with the center one on the screen, known as the "current line",
being highlighted in some way. In left mode, an inverse video highlight covers
the name field, while in right mode the cursor is in the column corresponding
to the mark date. At the bottom of the display are the labels for the "special
function keys." There are eight labels, corresponding to the eight function keys
marked f1 through f8 on the keyboard. Finally, messages from the program and 
prompts for information occur in the small area just above the key labels.

By the way -- anytime you see an inverse video highlight bar with the cursor
in the bar some place, you can type and change the content of the item. This is
true whether the bar is in the data base (on the current line) or in the
message area (as a result of some an input request from the program.)
The bar shows exactly how much text you can put there. The various editing keys
on the keyboard such as delete character, left and right arrows, etc, function
as you might expect (for more details, see below). 

As is true with most editors, the pew program reads in the named or default
file at the beginning of program execution, and all edits made by the user
occur in main memory. Thus it becomes the responsibility of the user, prior to
terminating the program, to ask the program to save (ie., make permanent) all 
the changes that the user has made. This is accomplished with the "save" key.
This key will ask for a file name, supplying a default which is the last file 
name used (possibly the default chosen by the program at startup). 

Almost anything you do while using the program can be "undone", so don't be
afraid of it. If all else fails, exit the program without saving the changes
and your database will be exactly as it was before you started. In general,
here's how to "fix" your mistakes:
	
	If you just marked a person present and they weren't, just press
	the "cancel" special function key -- it un-marks people.

	If you pressed a special function key ("search", "save", "exit", etc.) 
	and don't really want that function (or don't know what it's asking you)
	just press the "cancel" key.

	If you accidently pressed the Delete-line key, just press Insert-line.

	If you typed characters into the name field of the data base, just
	move the cursor left with the arrow keys and re-type the correct ones.



The following table describes the various keys' effects in the
two different modes:

Key:		Left mode:			Right Mode:

up		move to previous line		same
		but not past start of list

down		move to next line		same
		but not past end of list

return		same as "down"			same

right		move cursor right in field	bump date to next week
		but not past field end

left		move cursor left in field	bump date to previous week
		but not past start of field

backspace	same as "left"			no-op

tab, s-tab	change to right mode		reset date to default and
						change to left mode

prev		same as 10 "up"			same

next		same as 10 "down"		same

home-up		same as repeated "up"		same

home-down	same as repeated "down"		same

clear-line	clears field from cursor on	no-op

s-clear-line	clears entire field		no-op

clear-display	redraws the display		same

s-clear-display	same as "home-up"		same

insert-line	opens a line in front of 	same
		current line. If there is
		a line on the "stack", pop the
		stack and place that data into
		the newly open'd line.

delete-line	deletes the current line, 	same
		but pushes it on the top
		of the "stack"

insert-char	toggles insert char mode	no-op

delete-char	deletes current character	no-op
		current record

f1 - mark	marks the current record at 	marks the current field at
		the default date		the current date

f2 - cancel	cancels current operation	same
		(un-does mark if there is
		no "current operation")

f3 - alpha	asks for a name, then searches	same
		forward in the database for
		the first location where that 
		name should be inserted. If no 
		name is given, the current top 
		of "stack" is used. Otherwise 
		the name entered is pushed onto 
		the "stack" in anticipation of 
		an insert-line. This "alphabe-
		tizing" can fail to locate the
		correct spot, in which case
		selecting the location by hand
		will be required.

f4 - search	works like f3 (alpha) except 	same
		that the database is searched
		for an exact match with the
		target name.
	
f5 - read	if the current file hasn't	same
		been written since changes,
		prompts for confirmation and 
		then clears memory. Asks for 
		a file name to read. 

f6 - save	asks for a file name to save 	same
		to, then writes data to file.

f7 - print?	toggles the "printability" 	same
		flag for the current record
		and displays in the prompt
		area the new value.

f8 - exit	if the current file hasn't	same
		been written since changes, 
		prompts for confirmation. Then
		terminates the program.

graphic keys	inserted in front of, or	replaces the character
(i.e, typing	replace the character 		indicated by the cursor
keys)		indicated by the cursor

non-graphics	no-op				no-op
(e.g., control 
keys)

