/* 1oo% C/Wall by Neurodancer/1oo% */

/* --- sysop definable values ------------------------------------------ */

mxl=39				/* maximum lines to store                */
anonym=1			/* allow anonymous tagging 1=yes 0=no    */
defcol=6			/* default color of taglines		 */
txt='hit a kEy if you cAn'	/* the blinking text after re-display:	 */
                                /* DON'T USE MCI HERE! WON'T WORK!       */

/* --------------------------------------------------------------------- */

ver='$VER: C/Wall v1.7a (12-Dec-96) by Neurodancer'
parse var ver +6 prg! vrs! dat!' by 'auth!
changewhere prg!' 'vrs!

options results /* ;signal on SYNTAX;signal on ERROR;signal on IOERR */
tr=transmit;ss=sendstring;gc=getchar;gu=getuser;mg=maygetchar;pr=prompt
a='rexxsupport.library';if ~show('l',a) then if ~addlib(a,0,-30) then exit

gu 1311992;path=result;gu 28;tert=result;gu 1100468;trml=result;if trml>mxl then trml=mxl;gu 1100467;trmw=result

if tert=2 then do;wht='cf';cyn='ce';pur='cd';blu='cc';ylw='cb';grn='ca';red='c9';drk='c8';end
else do;wht='c7';cyn='c6';pur='c5';blu='c4';ylw='c3';grn='c2';red='c1';drk='c4';end

ln=0
if ~exists(path||'tt'tert'.wall_top') then do;call open(logo,path||'sys.wall_top','R');do until eof(logo);logo.ln=readln(logo);ln=ln+1;end;call close(logo);end
else do;call open(logo,path||'tt'tert'.wall_top','R');do until eof(logo);logo.ln=readln(logo);ln=ln+1;end;call close(logo);end

strtl=mxl-trml+ln+4;nwl=mxl+1

READ_WALL:
call open(rdata,path'1oo_Wall.data','R');do z=mxl to 0 by -1;wall.z=readln(rdata);parse var wall.z showname.z''tagline.z''author.z;end;call close(rdata)
call display(strtl,mxl,1)

ASK_ADD:
tr 'q1'cyn'-- q1Add a singleliner?       ['red'Noq1] ?0';gu 70;if ~result then signal schluss

INP_LINE:;linel=trmw-2
if anonym=1 then do;tr '^2[4Jq1'cyn'-- q1Anonymous?               ['red'Noq1] ?0';gu 70;if result then showname.nwl=0;else showname.nwl=1;end
else showname.nwl=0

gu 1;author.nwl=result
if showname.nwl=1 then linel=linel-(length(author.nwl)+3)

tr '^2[4Jq1'cyn'-- q1Enter up to 'ylw||linel' q1chars, <'ylw'CRq1> to quit.'
ss '@2}'cyn'i136 'linel'}';gu 70;tagline.nwl=result

if tagline.nwl='###PANIC' then signal SCHLUSS
if tagline.nwl='' then do;tr '^2q1[4J'cyn'-- q1Empty line! Quit?       ['grn'Yesq1] ?1';gu 70;if ~result then call inp_line;else signal schluss;end

oldlen=length(tagline.nwl)
tagline.nwl=replace(tagline.nwl,'ä','ae');tagline.nwl=replace(tagline.nwl,'Ä','Ae');tagline.nwl=replace(tagline.nwl,'ö','oe');tagline.nwl=replace(tagline.nwl,'Ö','Oe');tagline.nwl=replace(tagline.nwl,'ü','ue');tagline.nwl=replace(tagline.nwl,'Ü','Ue');tagline.nwl=replace(tagline.nwl,'ß','ss');tagline.nwl=replace(tagline.nwl,d2c(196),'Ae');tagline.nwl=replace(tagline.nwl,d2c(132),'ae');tagline.nwl=replace(tagline.nwl,d2c(153),'Oe');tagline.nwl=replace(tagline.nwl,d2c(148),'oe');tagline.nwl=replace(tagline.nwl,d2c(129),'ue');tagline.nwl=replace(tagline.nwl,d2c(154),'Ue');tagline.nwl=replace(tagline.nwl,d2c(225),'ss')
if length(tagline.nwl)>oldlen+length(author.nwl)+3 then tagline.nwl=left(tagline.nwl,79-length(author.nwl)-3)

if showname.nwl=0 then tr '@2^2[4J'wht||tagline.nwl;else tr '@2^2[4J'wht||left(tagline.nwl,79-length(author.nwl)-3)||' '||blu'('wht||author.nwl||blu')'
tr 'q1[4J'cyn'-- q1Is this okey?           ['grn'Yesq1] ?1';gu 70;if ~result then do;tr '^2[4J';SIGNAL inp_line;end
tr '^3[4Jq1'cyn'-- q1Redisplay wall?          ['red'Noq1] ?0';gu 70;if ~result then SIGNAL write_wall
call display(strtl+1,nwl,0)
call blink('04c6effe6c4',2)

WRITE_WALL:
wall.nwl=showname.nwl''tagline.nwl''author.nwl
call open(wdata,path||'1oo_Wall.data','W');do z=nwl to 1 by -1;call writeln(wdata,wall.z);end;call close(wdata)

SCHLUSS:;bufferflush;exit

DISPLAY:;arg start,ende,mode
ss 'f'mode'}';do vw=0 to ln-2;tr logo.vw;end
do z=start to ende;ss 'c'||defcol||'}'
if showname.z=1 then tr left(tagline.z,79-length(author.z)-2)||blu'('wht||author.z||blu')'
else tr tagline.z;end
ss '^1* '||path||'sys.wall_bot}';return mode

REPLACE: procedure
parse arg a,b,c;d=index(a,b);do while d~=0;a=insert(c,delstr(a,d,length(b)),d-1);d=index(a,b);end
return a

BLINK:;arg c,d;z=1;p=1;l=length(txt);ss copies(' ',(trmw-l)%2)
do forever;mg;if result~='NOCHAR' then leave
ss 'c'substr(c,z,1)'}'txt'<'l'}';z=z+1;if z>length(c) then z=1;call delay(d)
end;transmit 'c7'txt'q1';return

SYNTAX:;ERROR:;IOERR:
eline='c9'||prg!||': :2Error '||rc||'n1'||errortext(rc)||')n1Line '||sigl||':0'
tr eline;logentry eline
bufferflush;exit

/* Don't sneak around this lousy ARexx code - call now: 08621-64260 v.34+ */
