/**************************************************************************\
         $VER: CNet Amiga PagerChat, v4.0 (31-Oct-94) by Dotoran!
\**************************************************************************/
options results;se=sendstring;gu=getuser;tr=transmit;gc=getchar
gu 15;access=result;gu 1311992;df=result;ver='v4.0 '
a=time('n');b=left(a,2)*60+substr(a,4,2);a=getclip('PagerWindow')
if a>'' then if b>=a+5 then se '#0'df'PagerCleanUp}'
call READCONFIG;call READGROUP;gu 1;handle=result;gu 3;name=result
gu 27;cols=result;gu 7;time=result%10;gu 23;port=result;user=handle' ('name')'
gu 2400088;max=result;gu 1500000;file='Out.'left(result,3)
gu 1100003;line=result+1;gu 2307386;epath=result
call open(f1,df||file,'r');do line;out=readln(f1);end;call close(f1)
pn='He he his She she her'
if multi=1 then do
    if cols<78 | gra=0 then do
        tr 'f1n3cbCNet ceAmiga cbPagerc6, cf'ver'c6!n1'
        tr 'z4ce  Available SysOps  z0n1'
        do i=1 to mtot;tr 'cb'right(i,2)'c6> ca'sys.i;end i
        se 'n1cfPage c6Which: cai64 2}';gu 70;a=result
        if a<1 | a>mtot then a=1; end
    if cols>78 & gra=1 then do ; row=(20-mtot)%2
        tr 'f1['row-2';30HcbCNet ceAmiga cbPagerc6, cfv'ver'c6!ce'
        tr '['row';30Hz4    Available SysOps    z0';do i=1 to mtot
        tr '['row+i';30Hz4  z0ca'center(sys.i,20)'z4  z0';end i
        tr '['row+i';30Hz4                        z0'
        tr '['row+i+1';32HcdArrows ceSelect cfSysOpc6,'
        tr '['row+i+2';32HccENTER caCreates cbPagec6.[s'
        r=1;do until c2d(a)=13
            se '['row+r';32Hc9'center(sys.r,20)'[u';gc;a=result
            if c2d(a)=27 then do 2 ; gc ; a=result ; end
            if a='A' then do;se '['row+r';32Hca'center(sys.r,20)
                r=r-1;if r=0 then r=mtot;end
            if a='B' then do;se '['row+r';32Hca'center(sys.r,20)
                r=r+1;if r>mtot then r=1;end; end ; a=r ; end
    end ; else a=1
sysopname=sys.a ; ge=ge.a ; po=pos.a ; id=id.a ; if ge=0 then ge=2
sysop=a;p1=subword(pn,ge*3-2,1);p2=subword(pn,ge*3-1,1)
p3=subword(pn,ge*3,1);call PARSE(ac,31)
if handle=sysopname then do
    se "n2c6You want to caPAGE ceyourself cd"sysopname
    tr "c6? I c9don't c6think so...";exit;end
a=getclip('Pager'port);if a='' then do;a=0;call setclip('Pager'port,a);end
if index(it.0,access)=0 & a=cb+1 then do
    se "n2c6You've cfpaged cd"sysopname"c6 the c9maximum c6number "
    tr "of times! If "p2"'s around, "p2"'ll caanswerc6...";exit;end
tr 'n2c6Enter A cbReason c6for Paging ca'sysopname'c6.';gu 1100661
    cancc=bittst(d2c(result+(result<0)*256),6)
se 'cf:cei144 35}';gu 70;reason=result
if reason='' then do;tr 'c9Abort';exit;end
if getclip('PagerWindow')~='' then do;tr 'n1c6A cbPager ceWindow c6is already c9active c6on cd'sysopname"'s c6screen.";exit;end
gu 12;date=result;if cc=1 & cancc=1 then do;gu 2225094;aa=result;online=-1
    call PARSE(pos.a,aa);do i=1 to words(it.0);getportid word(it.0,i);aa=result
if aa=-1 | aa~=id then iterate i;if aa=id then do;online=word(it.0,i);leave i
    end;end i
if online>-1 then do
    tr 'n1cd'sysopname' c6is caalready c6signed onto cfPort 'online'c6! Sending a ceChat Request c6now...'
    addkeys ('CC'online'!`'reason'`');exit;end;end
setobject reason;putuser 1307274;gu 1100729;page=result;gu 2121864+port*24
CanChat=BitTST(d2c(result),0)
if page=2 | (page=0 & CanChat=1) then do;paged=1;call CHATLOG
    call open(f1,'ram:chat.'port,'W')
        call writeln(f1,user);call writeln(f1,reason)
        call writeln(f1,sysopname);call writeln(f1,time)
        call writeln(f1,sysop);call close(f1)
    se 'n1c6Now c9Paging ca'sysopname'c6....n1'
    address command 'run >nil: rx 'df'Pager 'port
    aa='[0;34mº º[64C[1;36m³ ³'
    if gra=0 then tr 'n1cfPaging cb'sysopname'cf...'
    if cols>78 & gra=1 then do;gu 12;date=result
    date=translate('HIJ. EF, LMNO (QRSTUVm)',date,'ABCDEFGHIJKLMNOPQRSTUV')
    if substr(date,21,1)=' ' then date=delstr(date,21,2)
    if substr(date,16,1)=' ' then date=delstr(date,16,1)
    tr 'n1'center('cdA window similar to this one appeared on ce'sysopname"'s cdscreen:",88)
    tr '[34mÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ[36m¿'
    tr '[34mº[16C[37mCNet Amiga Pager, 'ver' Written by Dotoran![15C[36mÀÄ´'
    tr '[34mº ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ[36m¿ ³'
    tr '[34mº º[10C[33mPage[31m: cd'left(date' c6for cb'sysopname,61)' ce³ ³'
    tr '[34mº º[72C[36m³ ³'
    tr '[34mº º[10C[33mUser[31m: ca'left(handle' cf(ce'name'cf) c6Port ca'port,71)'ce³ ³';tr '[34mº º[72C[36m³ ³'
    tr '[34mº º[8C[33mReason[31m: cf"cd'left(reason'cf"',58)'ce³ ³'
    tr '[34mº Ó[36mÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ³'
    tr '[34mº ÉÍÍÍÍ[36m¿ [34mÉÍÍÍ[36m¿ [34mÉÍÍÍÍÍ[36m¿ [34mÉÍÍÍÍÍÍÍÍÍ[36m¿ [34mÉÍÍÍÍÍÍÍÍÍ[36m¿ [34mÉÍÍÍÍÍÍÍÍÍÍÍ[36m¿ [34mÉÍÍÍÍ[36m¿ [34mÉÍÍÍÍÍÍ[36m¿ ³'
    tr 'ccº ºcfChatce³ ccºcfOLMce³ ccºcfFSendce³ ccºcfTerminatece³ ccºcfGone In 5ce³ ccºcfUnavailablece³ ccºcfBusyce³ ccºcfo1Ignoreo0ce³ ³'
    tr '[34mº Ó[36mÍÄÄÄÙ [34mÓ[36mÍÄÄÙ [34mÓ[36mÍÄÄÄÄÙ [34mÓ[36mÍÄÄÄÄÄÄÄÄÙ [34mÓ[36mÍÄÄÄÄÄÄÄÄÙ [34mÓ[36mÍÄÄÄÄÄÄÄÄÄÄÙ [34mÓ[36mÍÄÄÄÙ [34mÓ[36mÄÄÄÄÄÄÙ ³'
    tr '[34mÓ[36mÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ'
    tr '   [35mIf 'p2" should press an underlined button, you'll receive an [33mOLM [35mMessage![0m";end
    if cols<78 | gra=0 then do;tr 'n1ca'sysopname' c6has been notified that you wish to chat. '
    tr 'n1'p1' ceMay c6or ceMay c9NOT c6be around.'
    tr 'n1'p1' will cdAnswer c6if 'p2' is available.'
    tr 'n1cbONE c9Page c6is caENOUGHc6.'
    se 'n1A window telling ca'sysopname'c6 that someone has '
    tr 'c9Paged c6stays on 'p3' screen.';end
end;else do
    se 'n1c9Sorryc6, ca'sysopname" c6isn't around right now.n2"p1"'s "out'n2c6Leave cbMail c6for ca'sysopname'c6? c7[caYesc7]c6: ca'
    gc;a=result;if a='N' then do;tr 'No.';paged=0;call CHATLOG;exit;end
    tr 'Yes!';setmailsubj strip(left(reason,30));cleareditor
    paged=2;call CHATLOG;calleditor 0;st=result;if st~=0 then do
    address command 'copy 'epath'_edbuff'port' 'epath'_edbuf'port
    call PARSE(mid.a,max);do i=1 to words(it.0);id=word(it.0,i);writemail id
    address command 'copy 'epath'_edbuf'port' 'epath'_edbuff'port
    end i;address command 'delete 'epath'_edbuf'port;end;end
READCONFIG:
    call open(f1,df'PagerConfigF','r')
      a=readln(f1);parse var a gra''cc''cb''ac''hr''j
      a=readln(f1);parse var a fpath''cost''kill''j
      a=readln(f1);parse var a chsp''chvo''j
      a=readln(f1);parse var a font''size''logN''logK''j
      a=readln(f1);parse var a multi''mtot''grp1''sys1''grp2''sys2''grp3''sys3''grp4''sys4''j
      do i=1 to mtot;sysop.i=readln(f1);end i
    call close(f1);return
READGROUP:
    call PARSE(grp1,31);if index(' 'it.0' ',' 'access' ')>0 then do
        call PARSE(sys1,mtot);signal GETSYSOPS;end
    call PARSE(grp2,31);if index(' 'it.0' ',' 'access' ')>0 then do
        call PARSE(sys2,mtot);signal GETSYSOPS;end
    call PARSE(grp3,31);if index(' 'it.0' ',' 'access' ')>0 then do
        call PARSE(sys3,mtot);signal GETSYSOPS;end
    call PARSE(grp4,31);if index(' 'it.0' ',' 'access' ')>0 then do
        call PARSE(sys4,mtot);sugnal GETSYSOPS;end
GETSYSOPS:
    do i=1 to c;a=it.i
        parse var sysop.a id.i''sys.i''ge.i''mid.i''pos.i''snd.i''say.i''j
    end i;mtot=c
  return
CHATLOG:
    call open(f1,'sysdata:log/'logN||id,substr('wa',exists('sysdata:log/'logN||id)+1,1))
    call writeln(f1,'ca'left(handle,25)'cd'date()'  cb'left(reason,39)'ce'substr('NYM',paged+1,1))
    call close(f1);return
PARSE:;it.='';c=0;it=translate(arg(1),'  ','.,')
    do a=1 to words(it);c=c+1;it.c=word(it,a)
    if index(it.c,'-')>0 then do;parse var it.c x'-'y
    if y='' then y=arg(2);if x='' then x=0;if x>y then do;d=x;x=y;y=d;end
    do b=x to y;it.c=b;c=c+1;end;c=c-1;end
    else if it.c>arg(2) | it.c<0 then do;c=c-1;iterate;end;end
    do i=1 to c;it.0=it.0||it.i' ';end;return c
SYNTAX:;ERROR:;IOERR:;e1=' c9Errorcf: ca'rc' cf(ca'errortext(rc)'cf)';e2='  c9Linecf: ce'left(sigl,4)'c9Filecf:'
    gu 1311992;a=result;gu 1311960;b=result;c='cb"ce'a||b'cb"';e2=e2' 'c;tr e1;tr e2;logentry e1;logentry e2;e=sourceline(sigl)
    do while e~='';e3='c9Sourcecf: cd'left(e,37);tr e3;logentry e3;e=substr(e,37);end;bufferflush;exit
/** Last Edited: 31-Oct-94 ************************************************\
\****************************************** FRONTIERS BBS (716)/823-9892 **/
