#! /bin/ksh

report-header Index

line2="================================================================="
line1="-----------------------------------------------------------------"

echo "$line1
This report is a quick reference format of the HCI programs,
using all terms in the insitution name, location, etc.
$line2"


function initstopwords
{
stopwords="The Of At And In For
College Univ University Department Institute Inst State
& a b c d e f g h i j k l m n o p q r s t u v w x y z"
echo "$stopwords" | tr ' ' '\012' >> /tmp/stopwords.$$
}

function nostopwords
	{
	fgrep -ivx -f /tmp/stopwords.$$ $*
	}

function expand_states
	{
	sed '
		s/USA-AL/United States, Alabama/
		s/USA-CA/United States, California/
		s/USA-CO/United States, Colorado/
		s/USA-GA/United States, Georgia/
		s/USA-KS/United States, Kansas/
		s/USA-MA/United States, Massachusetts/
		s/USA-MD/United States, Maryland/
		s/USA-MI/United States, Michigan/
		s/USA-NB/United States, Nebraska/
		s/USA-NC/United States, North Carolina/
		s/USA-NY/United States, New York/
		s/USA-OH/United States, Ohio/
		s/USA-OR/United States, Oregon/
		s/USA-PA/United States, Pennsylvania/
		s/USA-TN/United States, Tennessee/
		s/USA-TX/United States, Texas/
		s/USA-UT/United States, Utah/
		s/USA-VA/United States, Virginia/
		s/USA-WA/United States, Washington/
		'
	}

initstopwords

commasplit="%shortname
%country
%keyname"

function trimspace
	{
	sed 's/^[_ 	]*//
		s/[_ 	]*$//'
	}

for i in ${*-*}
do
	shortname=`sssearch section=unit $i | ssformat -t "%shortname"`
	sssearch section=unit $i |
		ssformat -t "$commasplit" | expand_states |
			tr ' ,' '_\012' | trimspace |
				dm INPUT "'${i##*/} $shortname'"
	sssearch section=unit $i |
		ssformat -t "%institution" |
				tr -cs "A-Za-z-&" '\012' |
					nostopwords | 
						dm INPUT "'${i##*/} $shortname'" 
done | sort -u | 2index | tr '_' ' '

