#!/bin/csh -f
setenv TERM vt100; set n=1; cd /afs/athena.mit.edu/user/b/e/belg4mit/ASCII
set dir = `ls -d [^A-Z]*[^~]`
start:
while(1)
	echo "				**** Pix ****"
	set n=1; set m=2; set o=3; set t=1
while( $o <= "$#dir")
	onintr action
	if( $t <= 3 )then
	echo " $n. $dir[$n]		 $m. $dir[$m]		 $o. $dir[$o]"
	set t = `expr $t + 1`
	else
	echo "$n. $dir[$n]		$m. $dir[$m]		$o. $dir[$o]"
	endif
	set n = `expr $n + 3`;	set m = `expr $m + 3`;	set o = `expr $o + 3`
end
action:
	echo ""
	echo "n to send		V:n to view		Q to quit"
	echo "";	echo "Action?";		set input = "$<"
	set input2 = `echo $input | cut -d : -f 2`
	set input = `echo $input | cut -d : -f 1`
	if( "$input" == "V" || "$input" == "v" ) goto view
	if( "$input" == "Q" || "$input" == "q" ) exit 0
	if( "$input" <= "$#dir" ) goto send
end
view:
$PAGER $dir[$input2];	sleep 2; clear
goto start
send:
echo "What color?";	set control = "$<"
if( "$control" == "" ) set control = "black"
echo "@color[$control]" >! /var/tmp/$user.pix
cat /afs/athena.mit.edu/user/b/e/belg4mit/ASCII/$dir[$input]\
	 >! /var/tmp/$user.pix2
/afs/athena/contrib/perl/perl -pi~ -e 's/@/@@/g' /var/tmp/$user.pix2
cat /var/tmp/$user.pix2 >>! /var/tmp/$user.pix
if( "$argv" == "" )then
	echo "To whom do you wish to send? ";	set recipient = "$<";
	if( "$recipient" == "" ) set recipient = "$user"
	z $recipient < /var/tmp/$user.pix
else
	z $argv < /afs/athena.mit.edu/user/b/e/belg4mit/ASCII/$dir[$input] -q
endif