\def\dup#1#2{
\setbox1=#1
\count1=#2
%\advance\count1 by1
\loop
\ifnum\count1>\number0
\advance\count1 by-1
\copy1
\repeat
}

\def\comment#1#2#3#4{{
% \dimen1 = width of space between head and text
% \dimen2 = width of text
% \dimen3 = temp storage for \hsize
% \dimen4 = computes integral number of lines
% \dimen5 = width of space between comment chars and head
%
% \box1 = comment delimiter with a strut
% \box2 = boldface header
% \box3 = text
% \box4 = column of comment delimiters
\parskip=0pt
\setbox1=\hbox{#1\strut}
\baselineskip=\ht1
\advance\baselineskip by \dp1
\setbox2=\hbox{\bf #3}
%%% set size of space between header and text
\ifdim\wd2=0pt
\dimen1=0em
\else
\dimen1=1em
\fi
%%% set size of space between comment chars and header
\ifdim\wd1=0pt
\dimen5=0em
\else
\dimen5=1em
\fi
%%% width of text = \hsize - indent - comment - comment/header space -
%%%		    header - header/text space
\dimen2=\hsize
\advance\dimen2 by-#2ex
\advance\dimen2 by-\wd1 \advance\dimen2 by-\dimen5
\advance\dimen2 by-\wd2 \advance\dimen2 by-\dimen1
%%% no indent
\parindent=0pt
%%% save \hsize
\dimen3=\hsize
%%% set \hsize to width of text
\hsize=\dimen2
%%% create box containing comment
\setbox3=\vtop{\strut\ignorespaces#4\strut}
%%% restore hsize
\hsize=\dimen3
%%% get integral number of lines of comment
\dimen4=\ht3
\advance\dimen4 by\dp3
\divide\dimen4 by\baselineskip
%%% make a column of comments this high
\setbox4=\vtop{\dup{\box1}{\dimen4}}
%%% put it all together
\hbox{\hskip#2ex\box4\hskip\dimen5\box2\hskip\dimen1\box3}
}}

\def\codebegin#1{\bgroup
\parindent=0pt
\parskip=0in
\hskip#1ex}

\def\codeend{\strut\par\egroup}

\def\code#1#2{\codebegin#1#2\codeend}
