%
%  CokeComm program for SIPB
%
%  Andrw Marc Greene
%  <amgreene@athena.mit.edu>
%  Student Information Processing Board, MIT
%  March 1989
%
\newif\ifamg
\newif\ifreal\realfalse
\newcount\cokesum\cokesum=0
%
%  Macros for typesetting each person's entry on the list
%
\def\person#1#2#3#4{%   Name, username, cans, paid
\vbox{%
\hbox{%
\hbox to 1.5in{\strut#1\hfill}\hbox to .5in{\hfill#3\quad}%
\hbox to .7in{\hfill\$#4\quad}\bubbles}%
\hbox{\hbox to 2.7in{\strut\tt #2\hfill}\bubbles}}\hrule}
%
%
\newbox\fivebubbles
\setbox\fivebubbles=\hbox{$\cal{O}\cal{O}\cal{O}\cal{O}\cal{O}\ $}
\def\five{\copy\fivebubbles}
\newbox\bubblebox
\setbox\bubblebox=\hbox{\five\five\five\five\five\qquad\five\five\five}
\def\bubbles{\copy\bubblebox}
%
\hsize=8in\hoffset=-.75in
%
\font\title=cmbx10 at 17.2667pt
\font\coltit=cmbx12
%
\headline={\hfil}
{\centerline{\title CokeComm Sheet}
\bigskip{}
\vbox{\hbox{
\strut\hbox to 1.5in{\coltit Name\hfill}\hbox to .5in{\coltit cans\hfill}%
\hbox to .7in{\coltit Balance\hfill}\hbox to \wd\bubblebox{\coltit
Soda\hfill {\sl --Fill in Circle--}\hfill Juice}}\hrule}}
\footline={\hfil}
%
\def\flush{\immediate\closeout3\closein2}
%
% Here's an old friend...  (from Animals)
%
\def\vread#1#2{\catcode`\^^M=9\catcode`\ =12\global\read#1 to #2}
%
%
% ---- END PREAMBLE ----
%
%  Last changed 20-Mar-89
%
\def\NextRecord{
\ifeof2\relax\amgfalse\else\amgtrue\fi
\ifamg\vread{2}{\pname}\fi
\ifeof2\relax\amgfalse\else\amgtrue\fi
\ifamg\vread{2}{\uname}\fi
\ifeof2\relax\amgfalse\else\amgtrue\fi
\ifamg\vread{2}{\obalance}\fi
\ifeof2\relax\amgfalse\else\amgtrue\fi
\ifamg\vread{2}{\ocans}\fi
}
%
\def\adddep{0}\def\sodas{0}\def\juices{0}
\immediate\openout3=coke.dat
\immediate\openin2=oldcoke.dat
\newcount\balance\newcount\cans\newcount\numb\newcount\dollars\newcount\rcount
\loop
\immediate\write16{----------------Next Person-----------------}
\NextRecord
\ifamg
\balance=\obalance
\cans=\ocans
\immediate\write16{\pname (\uname)}
\ifreal
\message{Total Deposits:}
\vread{-1}{\adddep}
\advance\balance by\adddep
\message{Enter sodas: }
\vread{-1}{\sodas}
\advance\cans by \sodas
\numb=\sodas
\multiply\numb by 40
\advance\balance by -\numb
\message{Enter juices: }
\vread{-1}{\juices}
\advance\cans by \juices
\numb=\juices
\multiply\numb by 45
\advance\balance by -\numb
\fi % ifreal
\edef\nbalance{\the\balance}
\global\advance\cokesum by \balance
\dollars=\balance
\divide\dollars by100
\multiply\dollars by100
\numb=\balance
\advance\numb by-\dollars
\divide\dollars by100
\def\sep{.}
\ifnum\numb<0 \multiply\numb by -1
\else
\ifnum\numb<10 \def\sep{.0}\fi
\fi
\def\bal{\the\dollars\sep\the\numb}
\edef\ncans{\the\cans}
\immediate\write3{\pname}
\immediate\write3{\uname}
\immediate\write3{\nbalance}
\immediate\write3{\ncans}
\immediate\write16{\pname : \uname : \ncans : \nbalance}
\person{\pname}{\uname}{\ncans}{\bal}\penalty-100
\ifreal\else\immediate\write16{**COKECOMM BALANCE = \the\cokesum}\fi
\repeat
\immediate\closeout3
\bye
