home *** CD-ROM | disk | FTP | other *** search
/ Jason Aller Floppy Collection / 341.img / TCS161S.ZIP / CHATSTUF.PAS < prev    next >
Pascal/Delphi Source File  |  1980-10-06  |  31KB  |  1,336 lines

  1. {$R-,S-,I-,D-,F+,V-,B-,N-,L+ }
  2. {$M 65500,0,0 }
  3.  
  4. unit chatstuf;
  5.  
  6. interface
  7.  
  8. uses crt,dos,
  9.      gentypes,gensubs,subs1,userret,flags,mainr1,modem,windows,statret,
  10.      configrt,qwik;
  11.  
  12. function specialcommand:boolean;
  13. procedure specialseries;
  14. procedure chat (gotospecial:boolean);
  15.  
  16. implementation
  17.  
  18. const c1=15;
  19.       c2=12;
  20.       c3=15;
  21.       c4=11;
  22.       w2=24;
  23.       w3=42;
  24.       axis1=9;
  25.       axis2=10;
  26.       edituser:array [1..12] of string=
  27.        ('╤═══════════════════╤',
  28.         '│ User Name         │',
  29.         '│ User Level        │',
  30.         '│ Xfer Level        │',
  31.         '│ Xfer Points       │',
  32.         '│ User Note         │',
  33.         '│ Time Left         │',
  34.         '│ Password          │',
  35.         '│ G-File Level      │',
  36.         '│ Board Access      │',
  37.         '│ Sysop Access      │',
  38.         '╘═══════════════════╛');
  39.       utils:array [1..12] of string=
  40.        ('╤═══════════════════╤',
  41.         '│ Hang up on User   │',
  42.         '│ NUKE User!        │',
  43.         '│ Snoop Mode [On]   │',
  44.         '│ Snoop Mode [Off]  │',
  45.         '╘═══════════════════╛',
  46.         '',
  47.         '',
  48.         '',
  49.         '',
  50.         '',
  51.         '');
  52.       extra:array [1..12] of string=
  53.        ('╤═══════════════════════════╤',
  54.         '│ Drop to DOS (all memory)  │',
  55.         '│ Drop to DOS (part memory) │',
  56.         '│ Run Config Program        │',
  57.         '│ Run Text Editor           │',
  58.         '╘═══════════════════════════╛',
  59.         '',
  60.         '',
  61.         '',
  62.         '',
  63.         '',
  64.         '');
  65.  
  66. var dscinc:array [1..6] of array [1..60] of word;
  67.     Status:word;
  68. type brdrrec = record
  69.                 TL,TH,TR,LV,RV,BL,BH,BR:char;
  70.                end;
  71.  
  72. const border:brdrrec = (TL:'╔';TH:'═';TR:'╗';
  73.                         LV:'║';       RV:'║';
  74.                         BL:'╚';BH:'═';BR:'╝');
  75.  
  76. function specialcommand:boolean;
  77.  
  78.   function getstring (t:anystr):anystr;
  79.   var mm,lz:anystr;
  80.   begin
  81.     textbackground (7);
  82.     textcolor (4);
  83.     gotoxy (axis1+3,axis2+2);
  84.     write (usr,t);
  85.     readline (mm);
  86.     getstring:=mm;
  87.   end;
  88.  
  89.   function getint (t:lstr):integer;
  90.   var s:sstr;
  91.   begin
  92.     s:=getstring (t);
  93.     getint:=valu(s)
  94.   end;
  95.  
  96.   function getboo (t:lstr):boolean;
  97.   var s:sstr;
  98.   begin
  99.     s:=getstring (t);
  100.     getboo:=upcase(s[1])='Y'
  101.   end;
  102.  
  103.  procedure box;
  104.  
  105.    procedure qbox (row,col,rows,cols:byte;wndwattr,brdrattr:integer;brdr:brdrrec);
  106.    begin
  107.     if (rows>=2) and (cols>=2) then
  108.     begin
  109.       with brdr do
  110.       begin
  111.         qwrite    (row       ,col                     ,brdrattr,TL);
  112.         qfilleos  (                           1,cols-2,brdrattr,TH);
  113.         qwriteeos (                                    brdrattr,TR);
  114.         qfill     (row+1     ,col       ,rows-2,1     ,brdrattr,LV);
  115.         qfill     (row+1     ,col+cols-1,rows-2,1     ,brdrattr,RV);
  116.         qwrite    (row+rows-1,col                     ,brdrattr,BL);
  117.         qfilleos  (                           1,cols-2,brdrattr,BH);
  118.         qwriteeos (                                    brdrattr,BR);
  119.         qfill     (row+1     ,col+1     ,rows-2,cols-2,wndwattr,' ')
  120.      end;
  121.     end;
  122.    end;
  123.  
  124.   begin
  125.    qstoretomem (axis1,axis2,6,60,dscinc);
  126.    qbox (axis1,axis2,6,60,15+lightgraybg,14,border);
  127.   end;
  128.  
  129.   procedure done1;
  130.   begin
  131.    qstoretoscr (axis1,axis2,6,60,dscinc);
  132.   end;
  133.  
  134.   procedure write1 (l:lstr);
  135.   begin
  136.    gotoxy (axis1+3,axis2+1);
  137.    textcolor (1);
  138.    textbackground (7);
  139.    writeln (usr,l);
  140.   end;
  141.  
  142.   procedure getnewtime;
  143.   var q:integer;
  144.       n:integer;
  145.   begin
  146.     n:=timeleft;
  147.     box;
  148.     write1 ('The user has '+strr(n)+' minutes left.');
  149.     q:=getint ('New time left for today? ');
  150.     if q>0 then begin
  151.       urec.timetoday:=urec.timetoday+(q-n);
  152.       writeurec;
  153.       writeln ('You have been granted '+strr(timeleft)+' minutes for today.')
  154.     end;
  155.   end;
  156.  
  157.   procedure getnewlevel;
  158.   var q,n:integer;
  159.   begin
  160.     box;
  161.     write1 ('Current Level: '+strr(ulvl));
  162.     q:=getint ('New Level [-1 to TRASH]: ');
  163.     if q>0 then begin
  164.      n:=q;
  165.      ulvl:=n;
  166.      urec.level:=n;
  167.      writeurec;
  168.      writeln ('You have been granted Level ',n,' access.');
  169.      if n=-1 then writeln ('That means you''ve been thrown off this system. Hahah.')
  170.     end
  171.   end;
  172.  
  173.   procedure getnewgflevel;
  174.   var q,n:integer;
  175.   begin
  176.     box;
  177.     write1 ('Current G-File Level: '+strr(urec.gflevel));
  178.     q:=getint ('New G-File Level: ');
  179.     if q>0 then begin
  180.      n:=q;
  181.      urec.gflevel:=n;
  182.      writeurec;
  183.      writeln ('You have been granted Level ',n,' G-File access.');
  184.     end
  185.   end;
  186.  
  187.   procedure getnewaccess;
  188.   var q,bname:sstr;
  189.       bn:integer;
  190.       ac:accesstype;
  191.       wasopen:boolean;
  192.       k:char;
  193.  
  194.     function inputaccess (q:sstr):accesstype;
  195.     begin
  196.       inputaccess:=invalid;
  197.       if length(q)=0 then exit;
  198.       case upcase(q[1]) of
  199.         'L':inputaccess:=letin;
  200.         'B':inputaccess:=bylevel;
  201.         'K':inputaccess:=keepout
  202.       end
  203.     end;
  204.  
  205.     procedure getallaccess;
  206.  
  207.       procedure setallaccess (ac:accesstype);
  208.       var cnt:integer;
  209.       begin
  210.         setalluserflags (urec,ac);
  211.         writeln ('Your access to all sub-boards: ',accessstr[ac]);
  212.         writeurec
  213.       end;
  214.  
  215.     begin
  216.       buflen:=1;
  217.       q:=getstring ('ALL acc. ([B]y level, [L]et in, [K]eep out, or CR): ');
  218.       ac:=inputaccess(q);
  219.       if ac<>invalid then setallaccess(ac)
  220.     end;
  221.  
  222.   var bd:boardrec;
  223.   begin
  224.     box;
  225.     write1 ('Change Sub-Board Access');
  226.     buflen:=10;
  227.     bname:=getstring ('Which sub-board to change access for [''*''/All]: ');
  228.     if length(bname)<1 then exit;
  229.     if bname='*' then
  230.       begin
  231.         getallaccess;
  232.         exit
  233.       end;
  234.     opentempbdfile;
  235.     bn:=searchboard(bname);
  236.     if bn=-1 then
  237.       begin
  238.         closetempbdfile;
  239.         write1 ('No such board!  Press any key..');
  240.         k:=bioskey;
  241.         exit
  242.       end;
  243.     write1 ('Board '+bname+'... Current access: '+accessstr[getuseraccflag(urec,bn)]);
  244.     buflen:=1;
  245.     q:=getstring ('Access ([B]y level, [L]et in, [K]eep out, or [CR]: ');
  246.     ac:=inputaccess(q);
  247.     if ac=invalid then begin
  248.       closetempbdfile;
  249.       exit
  250.     end;
  251.     setuseraccflag (urec,bn,ac);
  252.     writeurec;
  253.     closetempbdfile;
  254.     writeln ('New access for sub-board ',bname,': ',accessstr[ac])
  255.   end;
  256.  
  257.   procedure hangupyn;
  258.   var q:sstr;
  259.   begin
  260.     box;
  261.     write1 ('Hang up on User');
  262.     q:=getstring ('Hang up on him [y/n]? ');
  263.     if length(q)>0 then if upcase(q[1])='Y' then
  264.       begin
  265.         writeln ('<<< ',unam,' the System is going DOWN >>>    '^M^M);
  266.         hangup;
  267.         forcehangup:=true;
  268.         specialcommand:=true
  269.       end
  270.   end;
  271.  
  272.   procedure getnewname;
  273.   var m:mstr;
  274.       n:integer;
  275.       t:string[1];
  276.   begin
  277.     box;
  278.     write1 ('Current Name: '+unam);
  279.     m:=getstring ('New User Name: ');
  280.     if length(m)<>0 then begin
  281.       n:=lookupuser(m);
  282.       if n<>0 then begin
  283.         buflen:=1;
  284.         t:=getstring ('Name already exists!  Are you sure? ');
  285.         if upcase(t[1])<>'Y' then exit
  286.       end;
  287.       unam:=m;
  288.       urec.handle:=m;
  289.       writeurec;
  290.       writeln ('Your Name has been changed to ',unam,'.')
  291.     end
  292.   end;
  293.  
  294.   procedure getnewpassword;
  295.   var m:mstr;
  296.   begin
  297.     box;
  298.     write1 ('Current Password: '+urec.password);
  299.     m:=getstring ('New Password: ');
  300.     if length(m)<>0 then
  301.     begin
  302.       urec.password:=m;
  303.       writeurec;
  304.       writeln ('Your Password has been changed.')
  305.     end
  306.   end;
  307.  
  308.   procedure getxferlevel;
  309.   var i:integer;
  310.   begin
  311.     box;
  312.      write1 ('Current Xfer Level: '+strr(urec.udlevel));
  313.      i:=getint ('New File Xfer Level: ');
  314.      if i<0 then exit
  315.       else begin
  316.        writeln ('You have been granted Level ',i,' File Xfer access.');
  317.        urec.udlevel:=i;
  318.        writeurec;
  319.       end;
  320.   end;
  321.  
  322.   procedure getxferpoints;
  323.   var i:integer;
  324.   begin
  325.    box;
  326.     write1 ('Current Xfer Points: '+strr(urec.udpoints));
  327.     i:=getint ('New File Xfer Points: ');
  328.      if i<0 then exit
  329.       else begin
  330.        writeln ('You have been granted ',i,' File Xfer points.');
  331.        urec.udpoints:=i;
  332.        writeurec;
  333.       end;
  334.   end;
  335.  
  336.   procedure snoopmode;
  337.   begin
  338.     box;
  339.     write1 ('All I/O to the modem is locked.');
  340.     delay (500);
  341.     modeminlock:=true;
  342.     setoutlock (true)
  343.   end;
  344.  
  345.   procedure unsnoop;
  346.   begin
  347.     box;
  348.     write1 ('I/O to the modem is re-enabled.');
  349.     delay (500);
  350.     modeminlock:=false;
  351.     setoutlock (false)
  352.   end;
  353.  
  354.   procedure makenote;
  355.   var mastermind:mstr;
  356.   begin
  357.    box;
  358.    write1 ('Current Note: '+urec.note);
  359.    buflen:=30;
  360.    mastermind:=getstring ('New Note: ');
  361.    if length(mastermind)<>0 then begin
  362.     urec.note:=mastermind;
  363.     writeurec;
  364.     writeln ('Your User Note has been changed to: ',mastermind);
  365.    end;
  366.   end;
  367.  
  368.   procedure gotodos (i:integer);
  369.   begin
  370.     writeln ('[ Sysop in DOS ]');
  371.     window (1,1,80,25);
  372.     gotoxy (1,25);
  373.     writeln (usr,^M^J^J^J);
  374.     updateuserstats (false);
  375.     if i=1 then execcomcom else
  376.     if i=2 then begin
  377.      ensureclosed;
  378.      writereturnbat;
  379.      halt (4);
  380.     end;
  381.     ClrScr;
  382.   end;
  383.  
  384.   procedure dotexteditor;
  385.   begin
  386.     if length(editor)<1 then exit;
  387.     writeln ('[ Sysop is loading text editor ]');
  388.     window (1,1,80,25);
  389.     gotoxy (1,25);
  390.     writeln (usr,^M^J^J^J);
  391.     updateuserstats (false);
  392.     ensureclosed;
  393.     exec(GetEnv('COMSPEC'), '/C '+editor);
  394.   end;
  395.  
  396.   procedure printf (fn:lstr);
  397.  
  398.   procedure getextension (var fname:lstr);
  399.  
  400.     procedure tryfiles (a,b,c,d:integer);
  401.     var q:boolean;
  402.  
  403.       function tryfile (n:integer):boolean;
  404.       const exts:array [1..4] of string[3]=('','ANS','ASC','40');
  405.       begin
  406.         if not exist (fname+'.'+exts[n]) then tryfile:=false else begin
  407.           tryfile:=true;
  408.           fname:=fname+'.'+exts[n]
  409.         end
  410.       end;
  411.  
  412.     begin
  413.       if tryfile (a) then exit;
  414.       if tryfile (b) then exit;
  415.       if tryfile (c) then exit;
  416.       q:=tryfile (d)
  417.     end;
  418.  
  419.   begin
  420.     if pos ('.',fname)<>0 then exit;
  421.     if ansigraphics in urec.config  then tryfiles (2,3,1,4) else
  422.     if asciigraphics in urec.config then tryfiles (3,1,4,2) else
  423.     if eightycols in urec.config    then tryfiles (1,4,3,2) else
  424.                                          tryfiles (4,1,3,2)
  425.   end;
  426.  
  427. var tf:text;
  428.     k:char;
  429. begin
  430.   clearbreak;
  431.   writeln;
  432.   getextension (fn);
  433.   assign (tf,fn);
  434.   reset (tf);
  435.   iocode:=ioresult;
  436.   if iocode<>0 then begin
  437.     fileerror ('Printfile',fn);
  438.     exit
  439.   end;
  440.   clearbreak;
  441.   while not (eof(tf) or break or hungupon) do
  442.     begin
  443.       read (tf,k);
  444.       write (k)
  445.     end;
  446.   if break then writeln (^B);
  447.   writeln;
  448.   textclose (tf);
  449.   curattrib:=0;
  450.   ansireset
  451. end;
  452.  
  453.   procedure nuke;
  454.   var q:sstr;
  455.   begin
  456.     box;
  457.     q:=getstring ('NUKE the lamer [y/n]? ');
  458.     if length(q)>0 then if upcase(q[1])='Y' then
  459.       begin
  460.         write1 ('BOOM!!');
  461.         if exist (textfiledir+'Nuke') then
  462.          printf (textfiledir+'Nuke') else
  463.         writeln ('Your NUKED!!'^M^M);
  464.         hangup;
  465.         forcehangup:=true;
  466.         specialcommand:=true
  467.       end
  468.   end;
  469.  
  470.   procedure getsysopaccess;
  471.   const sysopstr:array [false..true] of string[6]=('Normal','Sysop');
  472.         sectionnames:array [udsysop..gfsysop] of string[20]=
  473.           ('File Transfer','Bulletin Section','Voting Booths',
  474.            'E-Mail Section','Doors','Main Menu','Databases','Trivia Sysop',
  475.            'G-File Section');
  476.   var cnt:configtype;
  477.       x:string[10];
  478.       n,mx:integer;
  479.       v:boolean;
  480.   begin
  481.     repeat
  482.       splitscreen (12);
  483.       mx:=1;
  484.       for cnt:=udsysop to gfsysop do begin
  485.         write (usr,mx:3,'. ',sectionnames[cnt]);
  486.         mx:=mx+1;
  487.         gotoxy (25,wherey);
  488.         writeln (usr,sysopstr[cnt in urec.config])
  489.       end;
  490.       write (usr,^M^J'Number to toggle [CR/Exit]: ');
  491.       buflen:=1;
  492.       readline (x);
  493.       n:=valu(x);
  494.       v:=(n>0) and (n<mx);
  495.       if v then begin
  496.         cnt:=configtype(ord(udsysop)+n-1);
  497.         if cnt in urec.config
  498.           then
  499.             begin
  500.               urec.config:=urec.config-[cnt];
  501.               x:='denied'
  502.             end
  503.           else
  504.             begin
  505.               urec.config:=urec.config+[cnt];
  506.               x:='granted'
  507.             end;
  508.         writeln ('You have been ',x,' sysop priveleges for the ',
  509.                  sectionnames[cnt],'.')
  510.       end
  511.     until not v;
  512.     writeurec;
  513.     splitscreen (17);
  514.     exit;
  515.   end;
  516.  
  517. procedure runconfig;
  518. begin
  519.  if forumdir[length(forumdir)]<>'\' then forumdir:=forumdir+'\';
  520.  Exec(GetEnv('COMSPEC'), '/C CONFIG.EXE');
  521.  readconfig;
  522.  if datascrambling then scrambled:=true else scrambled:=false;
  523. end;
  524.  
  525. procedure cursor (csize:byte);
  526. var regs:registers;
  527. begin
  528.    case (csize) of
  529.       1: if mem[0:$449]=7 then regs.cx:=$0c0d  { Underline  = 1 }
  530.          else regs.cx:=$0607;
  531.       2: if mem[0:$449]=7 then regs.cx:=$060d  { Full Block = 2 }
  532.          else regs.cx:=$0007;
  533.       3: regs.cx:=$2000;                       { No Cursor  = 3 }
  534.    end;
  535.    regs.ax:=$0100;
  536.    intr ($10,regs);
  537. end;
  538.  
  539. const memrows=25;
  540.       memcols=80;
  541. var scom:char;
  542.     k,c:char;
  543.     quit:boolean;
  544.     x,y:integer;
  545.  
  546. procedure writetop;
  547. begin
  548.   gotoxy (1,1);
  549.   textbackground (1);
  550.   textcolor (c1);
  551.   cursor (3);
  552.   write (usr,'╒═══════════════════════[ ');
  553.   textcolor (c2);
  554.   write (usr,'On-Line Sysop Commands');
  555.   textcolor (c1);
  556.   writeln (usr,' ]══════════════════════╕');
  557.   write (usr,'│ ');
  558.   textcolor (12);
  559.   write (usr,'User Editing          Utilities         Extra Commands');
  560.   textcolor (c1);
  561.   writeln (usr,'                │');
  562.   writeln (usr,'╘═══════════════════════════════════════════════════════════════════════╛');
  563.   gotoxy (1,16);
  564.   textcolor (15);
  565.   textbackground (4);
  566.  
  567.   write (usr,'< TCS Sysop Pull-Down Menu System - '+#24+','+#25+','+#26+','+#27+',Home,End to Move - [CR] to Select >');
  568.   textbackground (0);
  569. end;
  570.  
  571. procedure writebar (s:anystr);
  572. var monolith:integer;
  573. begin
  574.  textbackground (7);
  575.  textcolor (1);
  576.  for monolith:=1 to length(s) do
  577.  begin
  578.   if s[monolith] in [' '..'~'] then begin
  579.    textbackground (7);
  580.    textcolor (1);
  581.    write (usr,s[monolith]);
  582.   end else
  583.   begin
  584.    textbackground (1);
  585.    textcolor (c3);
  586.    write (usr,s[monolith]);
  587.   end;
  588.  end;
  589.  textbackground (1);
  590. end;
  591.  
  592. procedure movebar (xx:integer; dir:char);
  593. var satan,dogchild,floyd:integer;
  594. begin
  595.  dir:=upcase(dir);
  596.  case x of
  597.   1:begin
  598.      textcolor (c1);
  599.      textbackground (1);
  600.      satan:=y;
  601.      gotoxy (3,satan+2);
  602.      write (usr,edituser[satan]);
  603.      if dir='U' then y:=y-1 else
  604.      if dir='D' then y:=y+1 else
  605.      if dir='S' then y:=y;
  606.      if y>11 then y:=2;
  607.      if y<2 then y:=11;
  608.      gotoxy (3,y+2);
  609.      writebar (edituser[y]);
  610.     end;
  611.   2:begin
  612.      textcolor (c1);
  613.      textbackground (1);
  614.      dogchild:=y;
  615.      gotoxy (w2,dogchild+2);
  616.      write (usr,utils[dogchild]);
  617.      if dir='U' then y:=y-1 else
  618.      if dir='D' then y:=y+1 else
  619.      if dir='S' then y:=y;
  620.      if y>5 then y:=2;
  621.      if y<2 then y:=5;
  622.      gotoxy (w2,y+2);
  623.      writebar (utils[y]);
  624.     end;
  625.   3:begin
  626.      textcolor (c1);
  627.      textbackground (1);
  628.      floyd:=y;
  629.      gotoxy (w3,floyd+2);
  630.      write (usr,extra[floyd]);
  631.      if dir='U' then y:=y-1 else
  632.      if dir='D' then y:=y+1 else
  633.      if dir='S' then y:=y;
  634.      if y>5 then y:=2;
  635.      if y<2 then y:=5;
  636.      gotoxy (w3,y+2);
  637.      writebar (extra[y]);
  638.     end;
  639.  end;
  640. end;
  641.  
  642. procedure movebox (ex,ey:integer);
  643. var anarky,burger,two:integer;
  644. begin
  645.  cursor (3);
  646.  case ex of
  647.   1:begin
  648.      if x=2 then begin
  649.       gotoxy (w2,2);
  650.       textcolor (c2);
  651.       textbackground (1);
  652.       write (usr,' Utilities');
  653.       textcolor (c1);
  654.       gotoxy (w2,3);
  655.       write (usr,'═══════════════════════════');
  656.      end else
  657.      if x=3 then begin
  658.       gotoxy (w3,2);
  659.       textcolor (c2);
  660.       textbackground (1);
  661.       write (usr,' Extra Commands');
  662.       textcolor (c1);
  663.       gotoxy (w3,3);
  664.       write (usr,'═════════════════════════════');
  665.      end;
  666.      x:=1;
  667.      gotoxy (3,2);
  668.      textbackground (1);
  669.      textcolor (c4);
  670.      write (usr,'User Editing');
  671.      textcolor (c3);
  672.      for anarky:=1 to 12 do
  673.      begin
  674.       gotoxy (3,anarky+2);
  675.       write (usr,edituser[anarky]);
  676.      end;
  677.      if y>10 then y:=1;
  678.      textbackground (1);
  679.     end;
  680.   2:begin
  681.      if x=1 then begin
  682.       gotoxy (3,2);
  683.       textcolor (c2);
  684.       textbackground (1);
  685.       write (usr,'User Editing');
  686.       textcolor (c1);
  687.       gotoxy (3,3);
  688.       write (usr,'═════════════════════');
  689.      end else
  690.      if x=3 then begin
  691.       gotoxy (w3,2);
  692.       textcolor (c2);
  693.       textbackground (1);
  694.       write (usr,' Extra Commands');
  695.       textcolor (c1);
  696.       gotoxy (w3,3);
  697.       write (usr,'═════════════════════════════');
  698.      end;
  699.      x:=2;
  700.      gotoxy (w2,2);
  701.      textbackground (1);
  702.      textcolor (c4);
  703.      write (usr,' Utilities');
  704.      textcolor (c3);
  705.      for burger:=1 to 6 do
  706.      begin
  707.       gotoxy (w2,burger+2);
  708.       write (usr,utils[burger]);
  709.       textbackground (1);
  710.       textcolor (c3);
  711.      end;
  712.     end;
  713.   3:begin
  714.      if x=1 then begin
  715.       gotoxy (3,2);
  716.       textcolor (c2);
  717.       textbackground (1);
  718.       write (usr,'User Editing');
  719.       textcolor (c1);
  720.       gotoxy (3,3);
  721.       write (usr,'═════════════════════');
  722.      end else
  723.      if x=2 then begin
  724.       gotoxy (w2,2);
  725.       textcolor (c2);
  726.       textbackground (1);
  727.       write (usr,' Utilities');
  728.       textcolor (c1);
  729.       gotoxy (w2,3);
  730.       write (usr,'══════════════════════');
  731.      end;
  732.      x:=3;
  733.      gotoxy (w3,2);
  734.      textbackground (1);
  735.      textcolor (c4);
  736.      write (usr,' Extra Commands');
  737.      textcolor (c3);
  738.      for two:=1 to 6 do
  739.      begin
  740.       gotoxy (w3,two+2);
  741.       write (usr,extra[two]);
  742.       textbackground (1);
  743.       textcolor (c3);
  744.      end;
  745.     end;
  746.  end;
  747. end;
  748.  
  749. procedure eraseall;
  750. begin
  751.  qfill (4,1,11,80,black+blackbg,' ');
  752.  writetop;
  753. end;
  754.  
  755. procedure movedown (x,y:integer);
  756. begin
  757.  movebar (x,'D'); {y+1}
  758. end;
  759.  
  760. procedure moveup (x,y:integer);
  761. begin
  762.  movebar (x,'U'); {y-1}
  763. end;
  764.  
  765. procedure moveright (x,y:integer);
  766. begin
  767.  y:=1;
  768.  x:=x+1;
  769.  if x>3 then x:=1;
  770.  eraseall;
  771.  y:=1;
  772.  movebox (x,y);
  773.  movebar (x,'S');
  774. end;
  775.  
  776. procedure moveleft (x,y:integer);
  777. begin
  778.  y:=1;
  779.  x:=x-1;
  780.  if x<1 then x:=3;
  781.  eraseall;
  782.  y:=1;
  783.  movebox (x,y);
  784.  y:=1;
  785.  movebar (x,'S');
  786. end;
  787.  
  788. function processcommand:char;
  789. begin
  790.  cursor (1);
  791.  case x of
  792.   1:begin
  793.      case y of
  794.       2:getnewname;
  795.       3:getnewlevel;
  796.       4:getxferlevel;
  797.       5:getxferpoints;
  798.       6:makenote;
  799.       7:getnewtime;
  800.       8:getnewpassword;
  801.       9:getnewgflevel;
  802.       10:getnewaccess;
  803.       11:getsysopaccess;
  804.      end;
  805.     end;
  806.   2:begin
  807.      case y of
  808.       2:hangupyn;
  809.       3:nuke;
  810.       4:snoopmode;
  811.       5:unsnoop;
  812.      end;
  813.     end;
  814.   3:begin
  815.      case y of
  816.       2:Begin
  817.          gotodos (2);
  818.          Writetop;
  819.         End;
  820.       3:gotodos (1);
  821.       4:runconfig;
  822.       5:dotexteditor;
  823.      end;
  824.     end;
  825.  end;
  826.  cursor (3);
  827.  case x of
  828.   1:begin
  829.      case y of
  830.       2:processcommand:='N';
  831.       3:processcommand:='L';
  832.       4:processcommand:='F';
  833.       5:processcommand:='F';
  834.       6:processcommand:='R';
  835.       7:processcommand:='T';
  836.       8:processcommand:='P';
  837.       9:processcommand:='G';
  838.       10:processcommand:='B';
  839.       11:processcommand:='Y';
  840.      end;
  841.     end;
  842.   2:begin
  843.      case y of
  844.       2:processcommand:='H';
  845.       3:processcommand:='N';
  846.       4:begin
  847.          processcommand:='S';
  848.          quit:=true;
  849.         end;
  850.       5:begin
  851.          processcommand:='Z';
  852.          quit:=true;
  853.         end;
  854.      end;
  855.     end;
  856.   3:begin
  857.      case y of
  858.       2:processcommand:='D';
  859.       3:processcommand:='2';
  860.       4:processcommand:='C';
  861.       5:processcommand:='E';
  862.      end;
  863.      quit:=true;
  864.     end;
  865.  end;
  866.  done1;
  867. end;
  868.  
  869. begin
  870.   writeln (^B^M'[ Please wait ]');
  871.   splitscreen (17);
  872.   top;
  873.   clrscr;
  874.   specialcommand:=false;
  875.   x:=1;
  876.   y:=2;
  877.   writetop;
  878.   movebox (x,y);
  879.   movebar (x,'S');
  880.   quit:=false;
  881.   repeat
  882.    c:=bioskey;
  883.    case ord(c) of
  884.     27:begin
  885.         quit:=true;
  886.         scom:='Q';
  887.        end;
  888.     13:scom:=processcommand;
  889.     208:movedown (x,y);
  890.     200:moveup (x,y);
  891.     203:moveleft (x,y);
  892.     205:moveright (x,y);
  893.     199:begin
  894.          y:=2;
  895.          movebox (x,y);
  896.          movebar (x,'S');
  897.         end;
  898.     207:begin
  899.          if x>1 then y:=5 else y:=11;
  900.          movebox (x,y);
  901.          movebar (x,'S');
  902.         end;
  903.    end;
  904.   until quit;
  905.   cursor (1);
  906.   bottomline;
  907.   specialcommand:=scom in ['Q','S','Z','D','2','C','E'];
  908.   unsplit
  909. end;
  910.  
  911. procedure specialseries;
  912. begin
  913.   repeat until specialcommand
  914. end;
  915.  
  916. procedure chat (gotospecial:boolean);
  917. var k:char;
  918.     cnt,displaywid:integer;
  919.     quit,carrierloss,fromkbd:boolean;
  920.     baudstr,commstr:mstr;
  921.  
  922.                        (*--Variable Definitions----*)
  923.  
  924.  
  925.     xsys     :byte;       (*--X location of cursor for sysop--*)
  926.     ysys     :byte;       (*--Y locaiton of cursor for sysop--*)
  927.     xusr     :byte;       (*--X location of cursor for user---*)
  928.     yusr     :byte;       (*--Y location of cursor for user---*)
  929.     curcolor :byte;       (*--Stores current typists color----*)
  930.     ec       :byte;       (*--Stores old color for speed inc--*)
  931.     initi    :boolean;    (*--Amount of times of initia-------*)
  932.     linebufs :string[80]; (*--Storage of what sysop types-----*)
  933.     linebufu :string[80]; (*--Storage of what usr types-------*)
  934.  
  935. (*-Initialization of all the variables takes place-------------------------*)
  936. procedure init;
  937. begin
  938.   xsys     :=1;
  939.   ysys     :=4;
  940.   xusr     :=1;
  941.   yusr     :=14;
  942.   curcolor :=1;
  943.   ec       :=1;
  944.   initi    :=true;
  945.   linebufs :='';
  946.   linebufu :='';
  947. end;
  948.  
  949.  
  950. (*-Sends to screen location X,Y depending on values passed as X,Y----------*)
  951. procedure sendxy (x,y:byte);
  952. begin
  953.  write(#27+'[',y,';',x,'f');
  954.  
  955. end;
  956.  
  957.  
  958. (*-Clears entire screen via esc[2J-----------------------------------------*)
  959. Procedure clearscre;
  960. var i:byte;
  961.  begin
  962. for I:=4 to 22 do
  963.   begin
  964.    sendxy(1,i);
  965.    write(#27'[K');
  966.   end;
  967.  end;
  968.  
  969.  
  970. (*-Sets color if color is same as old, increases speed by not re-setting it*)
  971. Procedure setc;
  972. begin
  973.    if fromkbd then ec:=urec.statcolor else ec:=urec.inputcolor;
  974.    if curcolor<>ec then begin
  975.    curcolor:=ec;
  976.    modeminlock:=true;
  977.    ansicolor (curcolor);
  978.    modeminlock:=false;
  979.   end;
  980. end;
  981.  
  982. function parsedate (date:anystr):lstr;
  983. const months: array[1..12] of string[3]=('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
  984.  
  985. var m,d,y,inc,gog:sstr;
  986.     year,month,day,dayofweek:word;
  987. begin
  988.  if length(date)<>8 then begin
  989.   parsedate:=date;
  990.   exit;
  991.  end else
  992.  begin
  993.   m:=copy (date,1,2);
  994.   d:=copy (date,4,2);
  995.   y:=copy (date,7,2);
  996.   gog:=months[valu(m)];
  997.   getdate (year,month,day,dayofweek);
  998.   inc:=copy (strr(year),1,2);
  999.   parsedate:=gog+' '+d+' '+inc+y;
  1000.  end;
  1001. end;
  1002.  
  1003. (*---Displays middle line in urec.regular color----------------------------*)
  1004.  procedure midline;
  1005.  begin
  1006.    sendxy(1,13);
  1007.    write(^R'═══════════════════════════════════════════════════════════════════════════════');
  1008.    sendxy(25,13);
  1009.    write (^S'[ '^P'TCS '+ver+' - '+parsedate(date)+^S' ]');
  1010.  
  1011.    sendxy(trunc((21-length(sysopname))/2),13);
  1012.    write (^R'╡ '^S+sysopname+^R' ╞');
  1013.    sendxy(trunc((24-length(urec.handle))/2)+52,13);
  1014.    write (^R'╡ '^S+urec.handle+^R' ╞');
  1015.  end;
  1016.  
  1017. (*-Procedure Clears either lines 4-13 or 14-22 depending on WHERE:boo------*)
  1018. Procedure cle (malig:byte);
  1019. var i    :byte;  (*Loop variable - no usage*)
  1020. begin
  1021. if malig=0 then
  1022. begin
  1023.   for i:=4 to 12 do
  1024.  begin
  1025.   sendxy(1,i);
  1026.   write(#27'[K');
  1027.  end;
  1028.  sendxy(1,4);
  1029.  malig:=0;
  1030.  midline;
  1031. end;  (*  lines 4-12  *)
  1032.  
  1033. if malig=1 then
  1034. begin
  1035.   for i:=14 to 22 do
  1036.  begin
  1037.   sendxy(1,i);
  1038.   write(#27,'[K');
  1039.  end;
  1040.  sendxy(1,14);
  1041.  malig:=0;
  1042.  midline;
  1043. end;  (*  lines 14-22  *)
  1044.  
  1045.  
  1046. (*NOTE:  Line 13 is taken up by the middle line *)
  1047.  
  1048. end;
  1049.  
  1050.  
  1051.  
  1052.   procedure wordwrapit(yeanea:byte);
  1053.   var cnt       :byte;
  1054.       wl        :integer;
  1055.       ww        :lstr;
  1056.       cutarea   :byte;
  1057.       done      :boolean;
  1058.   begin
  1059.    done:=false;
  1060.    cutarea:=0;
  1061.    cnt:=80;
  1062.    if yeanea=0 then
  1063.      begin
  1064.     repeat
  1065.       if not done and (copy(linebufs,cnt,1)=' ') then cutarea:=cnt;
  1066.       if (cutarea>0) and not done then
  1067.         begin
  1068.          ansicolor(urec.statcolor);
  1069.          sendxy(cutarea,ysys);
  1070.          write(#27'[K');
  1071.          inc(ysys);
  1072.          xsys:=1;
  1073.          sendxy(xsys,ysys);
  1074.          write(copy(linebufs,cutarea+1,80-cutarea));
  1075.          xsys:=length(copy(linebufs,cutarea+1,80-cutarea))+1;
  1076.          sendxy(xsys,ysys);
  1077.          dec(ysys);
  1078.          done:=true
  1079.         end;      (*If loop     *)
  1080.       dec(cnt);   (*decrements c*)
  1081.      until cnt=1; (*For CNT loop*)
  1082.     linebufs:='';
  1083.    end;           (*For YEANEA  *)
  1084.  
  1085.    if yeanea=1 then
  1086.    begin
  1087.    done:=false;
  1088.    cutarea:=0;
  1089.    cnt:=80;
  1090.     repeat
  1091.       if not done and (copy(linebufu,cnt,1)=' ') then cutarea:=cnt;
  1092.       if (cutarea>0) and not done then
  1093.         begin
  1094.          ansicolor(urec.inputcolor);
  1095.          sendxy(cutarea,yusr);
  1096.          write(#27'[K');
  1097.          inc(yusr);
  1098.          xusr:=1;
  1099.          sendxy(xusr,yusr);
  1100.          write(copy(linebufu,cutarea+1,80-cutarea));
  1101.          xusr:=length(copy(linebufu,cutarea+1,80-cutarea))+1;
  1102.          sendxy(xusr,yusr);
  1103.          dec(yusr);
  1104.          done:=true
  1105.         end;      (*If loop     *)
  1106.       dec(cnt);   (*decrements c*)
  1107.      until cnt=1; (*For CNT loop*)
  1108.     linebufu:='';
  1109.    end;           (*For YEANEA  *)
  1110.  
  1111. end;              (*For wordwrap*)
  1112.  
  1113.  
  1114. (*---Places cursor at correct position------------------------------------*)
  1115.  Procedure locate;
  1116.  begin
  1117.    if fromkbd then     (*Checks if typed by sysop*)
  1118.  begin
  1119.  
  1120.    if (xsys=80) and (ysys<12) then     (*Checks if at end of line*)
  1121.   begin
  1122.    wordwrapit(0);
  1123.    inc(ysys);
  1124.    if not ysys=13 then linebufs:='';
  1125.   end;
  1126.   if (ysys=12) and (xsys=80) then
  1127.   begin
  1128.   cle(0);
  1129.   ysys:=4;
  1130.   xsys:=1;
  1131.   sendxy(xsys,ysys);
  1132.   write(linebufs);
  1133.   sendxy(80-length(linebufs)+1,ysys);
  1134.   wordwrapit(0);
  1135.   inc(ysys);
  1136.   sendxy(xsys,ysys);
  1137.  end;
  1138.  
  1139.   sendxy(xsys,ysys);
  1140.   inc(xsys);
  1141.  end;
  1142.    if not fromkbd then     (*Checks if typed by user*)
  1143.  begin
  1144.    if (xusr=80) and (yusr<22) then     (*Checks if at end of line*)
  1145.   begin
  1146.    wordwrapit(1);
  1147.    inc(yusr);
  1148.    if not yusr=23 then linebufu:='';
  1149.   end;
  1150. if (yusr=22) and (xusr=80) then
  1151.  begin
  1152.    cle(1);
  1153.    yusr:=14;
  1154.    xusr:=1;
  1155.    sendxy(xusr,yusr);
  1156.    write(linebufu);
  1157.    sendxy(80-length(linebufu)+1,yusr);
  1158.    wordwrapit(1);
  1159.    inc(yusr);
  1160.    sendxy(xusr,yusr);
  1161.  end;
  1162.  
  1163.    sendxy(xusr,yusr);
  1164.    inc(xusr);
  1165.  end;
  1166. end;                   (*end of procedure*)
  1167.  
  1168.   procedure instruct;
  1169.   var i:integer;
  1170.   begin
  1171.  for i:=1 to 5 do
  1172.    begin
  1173.      sendxy(1,i);
  1174.      write(#27,'[K');
  1175.    end;
  1176.     splitscreen (3);
  1177.     top;
  1178.     clrscr;
  1179.     write (usr,'Now in Chat mode. Press [F1] to leave or [F2] for commands.');
  1180.     initi:=false;
  1181.     bottom;
  1182.     sendxy(1,4);
  1183.   end;
  1184.  
  1185.  
  1186.   procedure typedchar (k:char);
  1187.  
  1188.  
  1189.  
  1190.   begin
  1191.  
  1192.    locate;    (*  Puts cursor in right place *)
  1193.    begin;
  1194.    if fromkbd then linebufs:=linebufs+K;
  1195.    if not fromkbd then linebufu:=linebufu+K;
  1196.     setc;      (*  Sets up color for typing   *)
  1197.     write(k)
  1198.    end;
  1199.   end;
  1200.  
  1201. begin
  1202.   carrierloss:=false;
  1203.   chatmode:=false;
  1204.   writeln (^B^M);
  1205.   if wanted in urec.config then begin
  1206.     specialmsg ('(No longer wanted)');
  1207.     urec.config:=urec.config-[wanted];
  1208.     writeurec;
  1209.   end;
  1210.   if eightycols in urec.config then displaywid:=80 else displaywid:=40;
  1211.   if gotospecial then begin
  1212.     specialseries;
  1213.     exit
  1214.   end;
  1215.   clearbreak;
  1216.   nobreak:=true;
  1217.   writeln (^S'[SysOp Chat Started at ',Timestr(now),']');
  1218.   write (^M);
  1219.   writeln (^M^M^S,appear,^M^R);
  1220.   instruct;
  1221.   if not initi then
  1222. begin
  1223.    init;      (*  Sets up variables          *)
  1224.    clearscre; (*  Clears screen lines 4-22   *)
  1225.    midline;   (*  Draws middle line for chat *)
  1226. end;
  1227.  
  1228.   quit:=false;
  1229.  
  1230.   repeat
  1231.     linecount:=0;
  1232.     if (not carrierloss) and (not carrier) then begin
  1233.       carrierloss:=true;
  1234.       writeln (^M'Warning: There is no carrier present.'^M)
  1235.  
  1236.     end;
  1237.     repeat until keyhit or (carrier and (numchars>0));
  1238.     fromkbd:=keyhit;
  1239.     ingetstr:=true;
  1240.  
  1241.     read (directin,k);
  1242.     if k=#127 then k:=#8;
  1243.     if requestchat
  1244.       then if requestcom
  1245.         then
  1246.           begin
  1247.             quit:=specialcommand;
  1248.             if not quit then instruct;
  1249.             clearbreak;
  1250.             nobreak:=true;
  1251.           end
  1252.         else
  1253.           begin
  1254.             unsplit;
  1255.  
  1256.             writeln (^M^M^S,disappear,^M^R);
  1257.             write (^M);
  1258.              writeln (^S'[SysOp Chat ended at ',timestr(now),']');
  1259.             clearscre;
  1260.             quit:=true
  1261.           end;
  1262.     case ord(k) of
  1263.       8:begin
  1264.       if (xsys>0) and fromkbd then
  1265.        begin
  1266.           modeminlock:=true;
  1267.           dec(xsys);
  1268.           sendxy(xsys,ysys);
  1269.           write (' ');
  1270.           sendxy(xsys,ysys);
  1271.           linebufs:=copy(linebufs,1,length(linebufs)-1);
  1272.           modeminlock:=false;
  1273.         end;
  1274.       if (xusr>0) and not fromkbd then
  1275.        begin
  1276.           modeminlock:=true;
  1277.           dec(xusr);
  1278.           sendxy(xusr,yusr);
  1279.           write (' ');
  1280.           sendxy(xsys,ysys);
  1281.           linebufu:=copy(linebufu,1,length(linebufu)-1);
  1282.           modeminlock:=false;
  1283.         end;
  1284.      end;
  1285.       0:;
  1286.       13:begin
  1287.            writeln;
  1288.            bottomline;
  1289.           if fromkbd then begin
  1290.            xsys:=1;
  1291.            inc(ysys);
  1292.              if (ysys=13) and (xusr>-1) then    (*Checks if at end of row *)
  1293.               begin
  1294.                  cle(0);
  1295.                   setc;
  1296.                   ysys:=4;
  1297.                   xsys:=1;
  1298.                   sendxy(xsys,ysys);
  1299.                   write(linebufs);
  1300.                   ysys:=5;
  1301.                   sendxy(xsys,ysys);
  1302.                   setc;
  1303.               end;
  1304.           sendxy(xsys,ysys);
  1305.           linebufs:='';
  1306.           end;
  1307.  
  1308.           if not fromkbd then begin
  1309.            xusr:=1;
  1310.            inc(yusr);
  1311.              if (yusr=23) and (xusr>-1) then    (*Checks if at end of row *)
  1312.               begin
  1313.                  cle(1);
  1314.                   setc;
  1315.                   yusr:=14;
  1316.                   xusr:=1;
  1317.                   sendxy(xusr,yusr);
  1318.                   write(linebufu);
  1319.                   yusr:=15;
  1320.                   sendxy(xusr,yusr);
  1321.                   setc;
  1322.               end;
  1323.             sendxy(xusr,yusr);
  1324.           linebufu:='';
  1325.           end;
  1326.          end;
  1327.       32..126:typedchar (k);
  1328.       1..31:if fromkbd and carrier then sendchar(k)
  1329.     end
  1330.   until quit;
  1331.   clearbreak
  1332. end;
  1333.  
  1334. begin
  1335. end.
  1336.