home *** CD-ROM | disk | FTP | other *** search
/ Jason Aller Floppy Collection / 341.img / TCS161S.ZIP / BULLETIN.PAS < prev    next >
Pascal/Delphi Source File  |  1989-10-29  |  63KB  |  2,413 lines

  1.  
  2. {$R-,S-,I-,D-,F+,V-,B-,N-,O+ }
  3. {$M 65500,0,0 }
  4.  
  5. unit bulletin;
  6.  
  7. interface
  8.  
  9. uses crt,dos,overlay,
  10.      gentypes,configrt,statret,gensubs,subs1,subs2,subs3,
  11.      userret,textret,mainr1,mainr2,overret1,flags,mainmenu;
  12.  
  13. procedure bulletinmenu;
  14.  
  15. implementation
  16.  
  17. procedure bulletinmenu;
  18. var q,curbul,lastreadnum:integer;
  19.     b:bulrec;
  20.     reading,quitmasterinc,cscan:boolean;
  21.  
  22.  
  23.   procedure togglecscan;
  24.   begin
  25.    if cscan then cscan:=false else
  26.     cscan:=true;
  27.    writeln;
  28.    write (^R'Auto-Scan is now: '^S);
  29.    if cscan then writeln ('On') else writeln ('Off');
  30.    writeln;
  31.   end;
  32.  
  33.   procedure makeboard; forward;
  34.  
  35.   function sponsoron:boolean;
  36.   begin
  37.     sponsoron:=match(curboard.sponsor,unam)
  38.   end;
  39.  
  40.   procedure clearorder (var bo:boardorder);
  41.   var cnt:integer;
  42.   begin
  43.     for cnt:=0 to 255 do bo[cnt]:=cnt
  44.   end;
  45.  
  46.   procedure carryout (var bo:boardorder);
  47.   var u:userrec;
  48.       cnt,un:integer;
  49.  
  50.     procedure doone;
  51.     var cnt,q:integer;
  52.         ns,a1,a2:set of byte;
  53.     begin
  54.       fillchar (ns,32,0);
  55.       fillchar (a1,32,0);
  56.       fillchar (a2,32,0);
  57.       for cnt:=0 to 255 do begin
  58.         q:=bo[cnt];
  59.         if q in u.newscanconfig then ns:=ns+[cnt];
  60.         if q in u.access1 then a1:=a1+[cnt];
  61.         if q in u.access2 then a2:=a2+[cnt]
  62.       end;
  63.       u.newscanconfig:=ns;
  64.       u.access1:=a1;
  65.       u.access2:=a2;
  66.       seek (ufile,un);
  67.       write (ufile,u)
  68.     end;
  69.  
  70.   begin
  71.     writeln (^B'Adjusting user access flags...');
  72.     seek (ufile,1);
  73.     for un:=1 to numusers do begin
  74.       if (un mod 10)=0 then write (' ',un);
  75.       read (ufile,u);
  76.       if length(u.handle)>0 then doone
  77.     end
  78.   end;
  79.  
  80.   procedure switchboards (bnum1,bnum2:integer; var bo:boardorder);
  81.   var bd1,bd2:boardrec;
  82.       n1:integer;
  83.   begin
  84.     seekbdfile (bnum1);
  85.     read (bdfile,bd1);
  86.     seekbdfile (bnum2);
  87.     read (bdfile,bd2);
  88.     seekbdfile (bnum1);
  89.     writebdfile (bd2);
  90.     seekbdfile (bnum2);
  91.     writebdfile (bd1);
  92.     n1:=bo[bnum1];
  93.     bo[bnum1]:=bo[bnum2];
  94.     bo[bnum2]:=n1
  95.   end;
  96.  
  97.   procedure setfirstboard; forward;
  98.  
  99.   procedure seekffile (n:integer);
  100.   begin
  101.     seek (ffile,n-1)
  102.   end;
  103.  
  104.   function numfiles:integer;
  105.   begin
  106.     numfiles:=filesize (ffile)
  107.   end;
  108.  
  109.   procedure assignffile;
  110.   begin
  111.     assign (ffile,boarddir+curboardname+'.FIL')
  112.   end;
  113.  
  114.   procedure formatffile;
  115.   begin
  116.     close (ffile);
  117.     assignffile;
  118.     rewrite (ffile)
  119.   end;
  120.  
  121.   procedure openffile;
  122.   var f:filerec;
  123.       i:integer;
  124.   begin
  125.     close (ffile);
  126.     assignffile;
  127.     reset (ffile);
  128.     i:=ioresult;
  129.     if i<>0 then formatffile
  130.   end;
  131.  
  132.   procedure addfile (f:filerec);
  133.   begin
  134.     seekffile (numfiles+1);
  135.     write (ffile,f)
  136.   end;
  137.  
  138.   procedure delfile (fn:integer);
  139.   var f:filerec;
  140.       cnt:integer;
  141.   begin
  142.     for cnt:=fn to numfiles-1 do begin
  143.       seekffile (cnt+1);
  144.       read (ffile,f);
  145.       seekffile (cnt);
  146.       write (ffile,f)
  147.     end;
  148.     seekffile (numfiles);
  149.     truncate (ffile)
  150.   end;
  151.  
  152.   procedure seekbfile (n:integer);
  153.   begin
  154.     seek (bfile,n-1); che
  155.   end;
  156.  
  157.   function numbuls:integer;
  158.   begin
  159.     numbuls:=filesize(bfile)
  160.   end;
  161.  
  162.   procedure getlastreadnum;
  163.   var oldb:boolean;
  164.       b:bulrec;
  165.       lr:word;
  166.   begin
  167.     lastreadnum:=numbuls;
  168.     oldb:=false;
  169.     lr:=urec.lastread[curboardnum];
  170.     if lr=0
  171.       then lastreadnum:=0
  172.       else
  173.         while (lastreadnum>0) and (not oldb) do begin
  174.           seekbfile (lastreadnum);
  175.           read (bfile,b);
  176.           oldb:=b.id=lr;
  177.           if not oldb then lastreadnum:=lastreadnum-1
  178.         end
  179.   end;
  180.  
  181.   procedure assignbfile;
  182.   begin
  183.     assign (bfile,boarddir+curboardname+'.BUL')
  184.   end;
  185.  
  186.   procedure formatbfile;
  187.   begin
  188.     assignbfile;
  189.     rewrite (bfile);
  190.     curboardnum:=searchboard(curboardname);
  191.     if curboardnum=-1 then begin
  192.       curboardnum:=filesize(bdfile);
  193.       fillchar (curboard,sizeof(curboard),0);
  194.       writecurboard
  195.     end
  196.   end;
  197.  
  198.   procedure openbfile;
  199.   var b:bulrec;
  200.       i:integer;
  201.   begin
  202.     curboardnum:=searchboard (curboardname);
  203.     if curboardnum=-1 then begin
  204.       makeboard;
  205.       exit
  206.     end;
  207.     close (bfile);
  208.     assignbfile;
  209.     reset (bfile);
  210.     i:=ioresult;
  211.     if ioresult<>0 then formatbfile;
  212.     seekbdfile (curboardnum);
  213.     read (bdfile,curboard);
  214.     getlastreadnum;
  215.     openffile
  216.   end;
  217.  
  218.   function boardexist(n:sstr):boolean;
  219.   begin
  220.     boardexist:=not (searchboard(n)=-1)
  221.   end;
  222.  
  223.   procedure addbul (var b:bulrec);
  224.   var b2:bulrec;
  225.   begin
  226.     if numbuls=0 then b.id:=1 else begin
  227.       seekbfile (numbuls);
  228.       read (bfile,b2);
  229.       if b2.id=65535
  230.         then b.id:=1
  231.         else b.id:=b2.id+1
  232.     end;
  233.     seekbfile (numbuls+1);
  234.     write (bfile,b)
  235.   end;
  236.  
  237.   function checkcurbul:boolean;
  238.   begin
  239.     if (curbul<1) or (curbul>numbuls) then begin
  240.       checkcurbul:=false;
  241.       curbul:=0
  242.     end else checkcurbul:=true
  243.   end;
  244.  
  245.   procedure getbrec;
  246.   begin
  247.     if checkcurbul then begin
  248.       seekbfile (curbul);
  249.       read (bfile,b); che
  250.     end
  251.   end;
  252.  
  253.   procedure delbul (bn:integer; deltext:boolean);
  254.   var c,un:integer;
  255.       b:bulrec;
  256.       u:userrec;
  257.   begin
  258.     if (bn<1) or (bn>numbuls) then exit;
  259.     seekbfile (bn);
  260.     read (bfile,b);
  261.     if deltext then deletetext (b.line);
  262.     for c:=bn to numbuls-1 do begin
  263.       seekbfile (c+1);
  264.       read (bfile,b);
  265.       seekbfile (c);
  266.       write (bfile,b)
  267.     end;
  268.     seekbfile (numbuls);
  269.     truncate (bfile);
  270.     getlastreadnum
  271.   end;
  272.  
  273.   procedure delboard (bdn:integer);
  274.   var bd1:boardrec;
  275.       cnt,nbds:integer;
  276.       bo:boardorder;
  277.   begin
  278.     clearorder (bo);
  279.     nbds:=filesize(bdfile)-1;
  280.     if nbds=0 then begin
  281.       close (bdfile);
  282.       rewrite (bdfile);
  283.       exit
  284.     end;
  285.     for cnt:=bdn to nbds-1 do begin
  286.       seekbdfile (cnt+1);
  287.       read (bdfile,bd1);
  288.       seekbdfile (cnt);
  289.       writebdfile (bd1);
  290.       bo[cnt]:=cnt+1
  291.     end;
  292.     seek (bdfile,nbds);
  293.     truncate (bdfile);
  294.     seek (bifile,nbds);
  295.     truncate (bifile);
  296.     carryout (bo)
  297.   end;
  298.  
  299.   procedure sendfile (fn:integer);
  300.   var f:filerec;
  301.       cnt:integer;
  302.       k:char;
  303.       q:file of byte;
  304.   label exit;
  305.   begin
  306.     seekffile (fn);
  307.     read (ffile,f);
  308.     assign (q,f.fname);
  309.     reset (q);
  310.     iocode:=ioresult;
  311.     if iocode<>0 then begin
  312.       fileerror (f.fname,'SENDFILE (Ascii download)');
  313.       goto exit
  314.     end;
  315.     writelog (4,1,f.descrip);
  316.     writeln ('File:        '^S,f.descrip);
  317.     writeln ('Uploaded by: '^S,f.sentby);
  318.     writeln ('Downloaded:  '^s,f.downloaded);
  319.     writeln ('File size:   '^S,filesize(q),' characters'^M);
  320.     writeln (^B'Press [Space] when you are ready, or [X] to abort...');
  321.     repeat
  322.       repeat until charready;
  323.       k:=readchar;
  324.       if hungupon then goto exit;
  325.       if upcase(k)='X' then goto exit
  326.     until k=' ';
  327.     if not hungupon
  328.       then
  329.         begin
  330.           printfile (f.fname);
  331.           f.downloaded:=f.downloaded+1;
  332.           seekffile (fn);
  333.           write (ffile,f);
  334.           writeln (^B^M+asciidownload+^M'Press a key...');
  335.           repeat until charready;
  336.           k:=readchar
  337.         end;
  338.     exit:
  339.     close (q)
  340.   end;
  341.  
  342.   procedure receivefile (f:filerec);
  343.   var fn:lstr;
  344.       cnt,timeul:integer;
  345.       k:char;
  346.       done:boolean;
  347.       fff:text;
  348.       last3:array [1..3] of char;
  349.  
  350.     procedure putchar (k:char);
  351.     begin
  352.       write (fff,k);
  353.       write (usr,k)
  354.     end;
  355.  
  356.   begin
  357.     fn:='';
  358.     cnt:=1;
  359.     timeul:=timer;
  360.     repeat
  361.       if cnt<=length(f.descrip) then begin
  362.         k:=upcase(f.descrip[cnt]);
  363.         if k in ['A'..'Z'] then fn:=fn+k
  364.       end;
  365.       cnt:=cnt+1
  366.     until cnt>length(f.descrip);
  367.     if fn='' then fn:='Noname';
  368.     fn:=copy(fn,1,8);
  369.     while devicename(fn) do fn:=fn+chr(random(26)+64);
  370.     fn:=uploaddir+fn+'.';
  371.     cnt:=0;
  372.     repeat
  373.       cnt:=cnt+1
  374.     until (cnt=1000) or (not exist(fn+strr(cnt)));
  375.     if cnt=1000 then begin
  376.       writeln ('Please try another description!');
  377.       exit
  378.     end;
  379.     fn:=fn+strr(cnt);
  380.     assign (fff,fn);
  381.     rewrite (fff);
  382.     iocode:=ioresult;
  383.     if iocode<>0 then begin
  384.       error ('%I opening %1 in RECEIVEFILE (ASCII upload)','',fn);
  385.       exit
  386.     end;
  387.     f.fname:=fn;
  388.     f.sentby:=unam;
  389.     f.downloaded:=0;
  390.     f.when:=now;
  391.     writeln (^B'ASCII receive ready.'^M,
  392.              'Press [CR] and /E to end, /X to abort.'^M);
  393.     textcolor (outlockcolor);
  394.     repeat
  395.       repeat until charready;
  396.       if hungupon
  397.         then done:=true
  398.         else
  399.           begin
  400.             k:=chr(ord(readchar) and 127);
  401.             last3[1]:=last3[2];
  402.             last3[2]:=last3[3];
  403.             last3[3]:=upcase(k);
  404.             done:=((last3[1]=^M) or (last3[1]=^J))
  405.                   and (last3[2]='/') and ((last3[3]='E') or (last3[3]='X'));
  406.             if not done then begin
  407.               if (last3[2]=^M) and (k<>^J) then putchar (^J);
  408.               if last3[2]='/' then putchar ('/');
  409.               if k<>'/'
  410.                 then putchar (k)
  411.             end
  412.           end
  413.     until done;
  414.     textclose (fff);
  415.     textcolor (normbotcolor);
  416.     if last3[3]='E' then begin
  417.       addfile (f);
  418.       timeul:=timer-timeul;
  419.       if timeul<0 then timeul:=timeul+1440;
  420.       writeln (^B^M'That upload took ',timeul,' minutes.');
  421.       logontime:=logontime+timeul;
  422.       writelog (4,2,f.descrip)
  423.     end else begin
  424.       writestr (^M^M'Upload aborted!');
  425.       erase (fff);
  426.       iocode:=ioresult
  427.     end
  428.   end;
  429.  
  430.   procedure getbnum (txt:mstr);
  431.   var q:boolean;
  432.   begin
  433.     if length(input)>1
  434.       then curbul:=valu(copy(input,2,255))
  435.       else begin
  436.         writestr (^M'Message to '+txt+':');
  437.         curbul:=valu(input)
  438.       end;
  439.     q:=checkcurbul
  440.   end;
  441.  
  442. procedure killbul;
  443.   var un:integer;
  444.       u:userrec;
  445.   begin
  446.     writehdr ('Message Deletion');
  447.     if not reading then
  448.     getbnum ('delete');
  449.     if not checkcurbul then exit;
  450.     getbrec;
  451.     if (not match(b.leftby,unam)) and (not issysop) and (not sponsoron)
  452.       then begin
  453.         writeln ('You didn''t post that!');
  454.         exit
  455.       end;
  456.     writeln ('Subject: ',b.title,
  457.            ^M'Left by: ',b.leftby,^M^M);
  458.     writestr ('Delete this? *');
  459.     if not yes then exit;
  460.     un:=lookupuser (b.leftby);
  461.     if un<>0 then begin
  462.       writeurec;
  463.       seek (ufile,un);
  464.       read (ufile,u);
  465.       u.nbu:=u.nbu-1;
  466.       seek (ufile,un);
  467.       write (ufile,u);
  468.       readurec
  469.     end;
  470.     delbul (curbul,true);
  471.     if messages<1 then messages:=1;
  472.     messages:=messages-1;
  473.     if urec.lastmessages<1 then urec.lastmessages:=1;
  474.     urec.lastmessages:=urec.lastmessages-1;
  475.     writeln ('Message deleted.');
  476.     writelog (4,5,b.title)
  477.   end;
  478.  
  479.   procedure autodelete;
  480.   var cnt:integer;
  481.   begin
  482.     writeln (^R'Erasing first five posts '^I'-'^R' Please wait.');
  483.     for cnt:=6 downto 2 do delbul (cnt,true)
  484.   end;
  485.  
  486.   function wipe(amount:byte):string;
  487.   var z:integer;
  488.       gee:string[80];
  489.    begin
  490.    for z:=1 to amount do gee:=gee+' ';
  491.    wipe:=gee;
  492.    end;
  493.  
  494.   procedure postbul;
  495.   var l:integer;
  496.       m:message;
  497.       b:bulrec;
  498.       ds:longint;
  499.   begin
  500.     if ulvl<postlevel then begin
  501.       reqlevel(postlevel);
  502.       exit
  503.     end;
  504.     ds:=diskfree(0);
  505.     ds:=ds div 1000;
  506.     if ds<10 then begin
  507.      writeln;
  508.      writeln ('There is only '+strr(ds)+'K disk space left.');
  509.      writestr ('Are you sure you want to post? *');
  510.      if not yes then exit else
  511.     end;
  512.     l:=editor(m,true,'');
  513.     if l>=0 then
  514.       begin
  515.         inc(urec.nbu);
  516.         writeurec;
  517.         if messages>32760 then messages:=0;
  518.         inc(messages);
  519.         b.anon:=m.anon;
  520.         b.title:=m.title;
  521.         b.when:=now;
  522.         b.leftby:=unam;
  523.         b.status:='['+urec.note+']';
  524.         if sponsoron then b.status:=b.status+' [*Sponsor*]';
  525.         b.recieved:=false;
  526.         b.leftto:=m.leftto;
  527.         b.line:=l;
  528.         b.plevel:=ulvl;
  529.         addbul (b);
  530.         inc(newposts);
  531.         with curboard do
  532.           if autodel<=numbuls then autodelete
  533.       end
  534.   end;
  535.  
  536.   procedure readcurbul;
  537.   var q:anystr;
  538.       t:sstr;
  539.       cnt,emusux,anarkyamerika:integer;
  540.       oligarch:mstr;
  541.   begin
  542.     q:=wipe(80);
  543.     if checkcurbul then begin
  544.       getbrec;
  545.       if (ansi and not cscan) then begin
  546.        write (#27+'[2J');
  547.        clrscr;
  548.       end;
  549.       write   (^B^M^P'Message: '^S);
  550.       oligarch:=^S+strr(curbul)+' of '+strr(numbuls);
  551.       write (oligarch);
  552.       for emusux:=1 to 25-(length(oligarch)) do
  553.       write (' ');
  554.       if issysop or (not b.anon) then
  555.       writeln (^P'When: '^S,datestr(b.when),' at ',timestr(b.when),^R);
  556.       writeln (^P'Subject: '^S,b.title);
  557.       write   (^P'To:      '^S,b.leftto);
  558.       if (b.recieved) then begin
  559.        for anarkyamerika:=1 to 25-(length(b.leftto)+3) do
  560.        write (' ');
  561.        write (^P'-Received-'^R);
  562.       end;
  563.       writeln;
  564.       q:=^P'From:    '^S;
  565.       if b.anon then
  566.           begin
  567.             q:=q+anonymousstr;
  568.             if (issysop) or (ulvl>=readanonlvl) then q:=q+' ['+b.leftby+']'
  569.           end
  570.         else
  571.           begin
  572.             if b.plevel=-1
  573.               then t:='unknown'
  574.               else t:=strr(b.plevel);
  575.            q:=q+b.leftby+' (Level '+t+') '+b.status;
  576.           end;
  577.       writeln (q);
  578.       if break then exit;
  579.       printtext (b.line);
  580.       if match (b.leftto,unam) then begin
  581.        b.recieved:=true;
  582.        seekbfile (curbul);
  583.        write (bfile,b);
  584.       end;
  585.       ansicolor (urec.regularcolor);
  586.     end;
  587.   { if curbul>lastreadnum then }
  588.     begin
  589.       lastreadnum:=curbul;
  590.       urec.lastread[curboardnum]:=b.id
  591.     end
  592.   end;
  593.  
  594.   function queryaccess:accesstype;
  595.   begin
  596.     queryaccess:=getuseraccflag (urec,curboardnum)
  597.   end;
  598.  
  599.   procedure readbul;
  600.   begin
  601.     getbnum ('Read');
  602.     readcurbul
  603.   end;
  604.  
  605.   procedure readnextbul;
  606.   var t:integer;
  607.   begin
  608.     t:=curbul;
  609.     inc(curbul);
  610.     readcurbul;
  611.     if curbul=0 then curbul:=t
  612.   end;
  613.  
  614.   procedure readnum (n:integer);
  615.   begin
  616.     curbul:=n;
  617.     readcurbul
  618.   end;
  619.  
  620.   function haveaccess (n:integer):boolean;
  621.   var a:accesstype;
  622.   begin
  623.     curboardnum:=n;
  624.     seekbdfile (n);
  625.     read (bdfile,curboard);
  626.     a:=queryaccess;
  627.     if a=bylevel
  628.       then haveaccess:=ulvl>=curboard.level
  629.       else haveaccess:=a=letin
  630.   end;
  631.  
  632.   procedure makeboard;
  633.   begin
  634.     formatbfile;
  635.     formatffile;
  636.     with curboard do begin
  637.       shortname:=curboardname;
  638.       buflen:=30;
  639.       writestr (^M'Board Name: &');
  640.       boardname:=input;
  641.       buflen:=30;
  642.       writestr ('Sponsor [CR/'+unam+']:');
  643.       if input='' then input:=unam;
  644.       sponsor:=input;
  645.       writestr ('Minimum Level for entry:');
  646.       level:=valu(input);
  647.       writestr ('Autodelete after [CR/25]:');
  648.       if length(input)<1 then input:='25';
  649.       autodel:=valu(input);
  650.       if autodel<10 then begin
  651.         writeln ('Must be at least 10!');
  652.         autodel:=10
  653.       end;
  654.       setallflags (curboardnum,bylevel);
  655.       writecurboard;
  656.       writeln ('Board created.');
  657.       writelog (4,4,boardname+' ['+shortname+']')
  658.     end
  659.   end;
  660.  
  661.   procedure setactive (nn:sstr);
  662.  
  663.     procedure doswitch;
  664.     begin
  665.       openbfile;
  666.       curbul:=lastreadnum;
  667.       with curboard do
  668.       begin
  669.        writeln;
  670.        writeln (^R'╒═══════════╤════════════════════════════════╕');
  671.        write (^R'│ '^U'Sub-board'^R' │ '^S);
  672.        tab (boardname,31);
  673.        writeln (^R'│');
  674.        write (^R'│ '^U'Sponsor'^R'   │ '^S);
  675.        tab(sponsor,31);
  676.        writeln (^R'│');
  677.        write (^R'│ '^U'Messages'^R'  │ '^S);
  678.        tab (strr(numbuls),31);
  679.        writeln (^R'│');
  680.        write (^R'│ '^U'Last read'^R' │ '^S);
  681.        tab (strr(lastreadnum),31);
  682.        writeln (^R'│');
  683.        write (^R'│ '^U'Files'^R'     │ '^S);
  684.        tab (strr(numfiles),31);
  685.        writeln (^R'│');
  686.        writeln (^R'╘═══════════╧════════════════════════════════╛');
  687.        writeln;
  688.       end;
  689.     end;
  690.  
  691.     procedure tryswitch;
  692.     var n,s:integer;
  693.  
  694.       procedure denyaccess;
  695.       var b:bulrec;
  696.       begin
  697.         reqlevel (curboard.level);
  698.         setfirstboard
  699.       end;
  700.  
  701.     begin
  702.       curboardname:=nn;
  703.       curboardnum:=searchboard(nn);
  704.       if haveaccess(curboardnum)
  705.         then doswitch
  706.         else denyaccess
  707.     end;
  708.  
  709.   var b:bulrec;
  710.   begin
  711.     curbul:=0;
  712.     close (bfile);
  713.     close (ffile);
  714.     curboardname:=nn;
  715.     if boardexist(nn) then tryswitch else begin
  716.       writeln ('No such board: ',curboardname,'!');
  717.       if issysop
  718.         then
  719.           begin
  720.             writestr (^M'Create one [y/n]? *');
  721.             if yes
  722.               then
  723.                 begin
  724.                   makeboard;
  725.                   setactive (curboardname)
  726.                 end
  727.               else setfirstboard
  728.           end
  729.         else setfirstboard
  730.     end
  731.   end;
  732.  
  733.   function validbname (n:sstr):boolean;
  734.   var cnt:integer;
  735.   begin
  736.     validbname:=false;
  737.     if (length(n)=0) or (length(n)>8) then exit;
  738.     for cnt:=1 to length(n) do
  739.       if not (upcase(n[cnt]) in ['0'..'9','A'..'Z']) then exit;
  740.     validbname:=true
  741.   end;
  742.  
  743.   procedure listboards;
  744.     procedure spacelen(le:byte);
  745.    var aaa:byte;
  746.    begin
  747.     for aaa:=1 to le do
  748.     write(' ');
  749.    end;
  750.  
  751.   var cnt,oldcurboard:integer;
  752.       printed:boolean;
  753.   begin
  754.     oldcurboard:=curboardnum;
  755.     if exist (textfiledir+'Msgarea.BBS') then
  756.      printfile (textfiledir+'Msgarea.BBS') else
  757.     begin
  758.    writeln (^R'┌────────────────┬───────────────────────────────────────┬───────┬─────┐');
  759.    writeln (^R'│ '^U'Name'^R'           │ '^U'Subboard Name'^R'                         │ '^U'Level'^R' │ '^U'A/A'^R' │');
  760.    writeln (^R'├────────────────┼───────────────────────────────────────┼───────┼─────┤');
  761.     if break then exit;
  762.     for cnt:=0 to filesize(bdfile)-1 do
  763.       if haveaccess(cnt) then
  764.         with curboard do begin
  765.           write (^R'│ '^S,shortname,^R);
  766.           spacelen(15-length(shortname));
  767.           write (^R'│ '^S,boardname,^R);
  768.           spacelen(38-length(boardname));
  769.           write (^R'│ '^S,level,^R);
  770.           spacelen(6-length(strr(level)));
  771.        if anony then
  772.           writeLn (^R'│ '^S'YES'^R' │')
  773.        else
  774.           writeLn (^R'│ '^S'NO'^R'  │');
  775.           if break then exit
  776.         end;
  777.     end;
  778.     writeln (^R'└────────────────┴───────────────────────────────────────┴───────┴─────┘');
  779.     curboardnum:=oldcurboard;
  780.     seekbdfile (curboardnum);
  781.     read (bdfile,curboard)
  782.   end;
  783.  
  784.   procedure activeboard;
  785.   begin
  786.     if length(input)>1
  787.       then input:=copy(input,2,255)
  788.       else begin
  789.         listboards;
  790.         repeat
  791.           writestr (^M^M'Board Number [?/List]:');
  792.           if input='?' then listboards
  793.         until (input<>'?') or hungupon;
  794.       end;
  795.     if hungupon or (length(input)=0) then exit;
  796.     if input[1]='*' then input:=copy(input,2,255);
  797.     if validbname(input)
  798.       then setactive (input)
  799.       else
  800.         begin
  801.           writeln (^M'Invalid board name!');
  802.           setfirstboard
  803.         end
  804.   end;
  805.  
  806.   procedure setfirstboard; { FORWARD }
  807.   var fbn:sstr;
  808.   begin
  809.     if filesize(bdfile)=0 then exit;
  810.     if not haveaccess(0)
  811.       then error ('User can''t access first board','','');
  812.     seek (bifile,0);
  813.     read (bifile,fbn);
  814.     setactive (fbn)
  815.   end;
  816.  
  817.   procedure listbuls;
  818.   var cnt,bn:integer;
  819.       q:boolean;
  820.   begin
  821.     if length(input)>1 then begin
  822.       curbul:=valu(copy(input,2,255));
  823.       q:=checkcurbul
  824.     end;
  825.     if curbul=0
  826.       then
  827.         begin
  828.           writestr (^M'List titles starting at #*');
  829.           curbul:=valu(input)
  830.         end
  831.       else
  832.         if length(input)>1
  833.           then curbul:=valu(input)
  834.           else curbul:=curbul+10;
  835.     if not checkcurbul then curbul:=1;
  836.     writeln ('Titles:'^M);
  837.     for cnt:=0 to 9 do
  838.       begin
  839.         bn:=curbul+cnt;
  840.         if (bn>0) and (bn<=numbuls) then
  841.           begin
  842.             seekbfile (bn);
  843.             read (bfile,b);
  844.             write (bn,'. '^S,b.title,^R' by ');
  845.             if b.anon
  846.               then writeln (anonymousstr)
  847.               else writeln (b.leftby);
  848.             if break then exit
  849.           end
  850.       end
  851.   end;
  852.  
  853.   procedure editbul;
  854.   var me:message;
  855.   begin
  856.     getbnum ('edit');
  857.     if not checkcurbul then exit;
  858.     getbrec;
  859.     if (not match(b.leftby,unam)) and (not issysop) and (not sponsoron)
  860.       then begin
  861.         writeln ('You didn''t post that!');
  862.         exit
  863.       end;
  864.     reloadtext (b.line,me);
  865.     me.title:=b.title;
  866.     me.anon:=b.anon;
  867.     me.leftto:=b.leftto;
  868.     if reedit (me,true) then begin
  869.       writelog (4,6,b.title);
  870.       deletetext (b.line);
  871.       b.line:=maketext (me);
  872.       if b.line<0 then begin
  873.         writestr (^M'Deleting bulletin...');
  874.         delbul (curbul,false)
  875.       end else begin
  876.         seekbfile (curbul);
  877.         write (bfile,b)
  878.       end
  879.     end
  880.   end;
  881.  
  882.  
  883.   procedure sendbreply;
  884.   begin
  885.     if checkcurbul then begin
  886.       getbrec;
  887.       sendmailto (b.leftby,b.anon)
  888.     end else begin
  889.       getbnum ('reply to');
  890.       if checkcurbul then sendbreply
  891.     end
  892.   end;
  893.  
  894.   procedure listfiles;
  895.   var cnt,r1,r2,nfiles:integer;
  896.       f:filerec;
  897.   begin
  898.     nfiles:=numfiles;
  899.     thereare (nfiles,'file','files');
  900.     if nfiles=0 then exit;
  901.     parserange (nfiles,r1,r2);
  902.     if r1=0 then exit;
  903.     for cnt:=r1 to r2 do begin
  904.       seekffile (cnt);
  905.       read (ffile,f); che;
  906.       writeln (cnt,'. ',f.descrip);
  907.       if break then exit
  908.     end
  909.   end;
  910.  
  911.   function getfilenumber (txt:lstr):integer;
  912.   var fn:integer;
  913.       gotten:boolean;
  914.   begin
  915.     getfilenumber:=0;
  916.     input:=copy(input,2,255);
  917.     if length(input)=0 then
  918.       repeat
  919.         gotten:=true;
  920.         writestr (^M'File Number to '+txt+' [?/List]:');
  921.         if input='?' then
  922.           begin
  923.             writeln;
  924.             listfiles;
  925.             writeln;
  926.             gotten:=false
  927.           end
  928.       until gotten;
  929.     fn:=valu(input);
  930.     if (fn<1) or (fn>numfiles) then fn:=0;
  931.     getfilenumber:=fn
  932.   end;
  933.  
  934.   procedure downloadfile;
  935.   var fn:integer;
  936.   begin
  937.     fn:=getfilenumber ('download');
  938.     if fn<>0 then
  939.       begin
  940.         sendfile (fn);
  941.         urec.ndn:=urec.ndn+1
  942.       end;
  943.   end;
  944.  
  945.   procedure uploadfile;
  946.   var f:filerec;
  947.   begin
  948.     writestr ('Describe the file'+^M+'=> *');
  949.     if length(input)<>0 then begin
  950.       f.descrip:=input;
  951.       receivefile (f);
  952.       urec.nup:=urec.nup+1
  953.     end
  954.   end;
  955.  
  956.   procedure boardsponsor;
  957.  
  958.     procedure getbgen (txt:mstr; var q);
  959.     var s:lstr absolute q;
  960.     begin
  961.       writeln (^B'Current ',txt,': ',s);
  962.       buflen:=30;
  963.       writestr ('Enter new '+txt+': &');
  964.       if length(input)>0 then s:=input
  965.     end;
  966.  
  967.     procedure getbint (txt:mstr; var i:integer);
  968.     var a:anystr;
  969.     begin
  970.       a:=strr(i);
  971.       getbgen (txt,a);
  972.       i:=valu(a);
  973.       writecurboard
  974.     end;
  975.  
  976.     procedure getbstr (txt:mstr; var q);
  977.     begin
  978.       getbgen (txt,q);
  979.       writecurboard
  980.     end;
  981.  
  982.     procedure setacc (ac:accesstype; un:integer);
  983.     var u:userrec;
  984.     begin
  985.       seek (ufile,un);
  986.       read (ufile,u);
  987.       setuseraccflag (u,curboardnum,ac);
  988.       seek (ufile,un);
  989.       write (ufile,u)
  990.     end;
  991.  
  992.     function queryacc (un:integer):accesstype;
  993.     var u:userrec;
  994.     begin
  995.       seek (ufile,un);
  996.       read (ufile,u);
  997.       queryacc:=getuseraccflag (u,curboardnum)
  998.     end;
  999.  
  1000.     procedure setnameaccess;
  1001.     var un,n:integer;
  1002.         ac:accesstype;
  1003.         q,unm:mstr;
  1004.     begin
  1005.       writestr (^M'Change Access for User:');
  1006.       un:=lookupuser(input);
  1007.       if un=0 then begin
  1008.         writeln ('No such user!');
  1009.         exit
  1010.       end;
  1011.       unm:=input;
  1012.       ac:=queryacc(un);
  1013.       writeln (^B^M'Current access: ',accessstr[ac]);
  1014.       getacflag (ac,q);
  1015.       if ac=invalid then exit;
  1016.       if un=unum then writeurec;
  1017.       setacc (ac,un);
  1018.       if un=unum then readurec;
  1019.       case ac of
  1020.         letin:n:=1;
  1021.         keepout:n:=2;
  1022.         bylevel:n:=3
  1023.       end;
  1024.       writelog (5,n,unm)
  1025.     end;
  1026.  
  1027.     procedure setallaccess;
  1028.     var cnt:integer;
  1029.         ac:accesstype;
  1030.         q:mstr;
  1031.     begin
  1032.       writehdr ('Set Everyone''s Access');
  1033.       getacflag (ac,q);
  1034.       if ac=invalid then exit;
  1035.       writeurec;
  1036.       setallflags (curboardnum,ac);
  1037.       readurec;
  1038.       writeln ('Done.');
  1039.       writelog (5,4,accessstr[ac])
  1040.     end;
  1041.  
  1042.     procedure listaccess;
  1043.  
  1044.       procedure listacc (all:boolean);
  1045.       var cnt:integer;
  1046.           a:accesstype;
  1047.           u:userrec;
  1048.  
  1049.         procedure writeuser;
  1050.         begin
  1051.           if all
  1052.             then
  1053.               begin
  1054.                 tab (u.handle,30);
  1055.                 if a=bylevel
  1056.                   then writeln ('Level='+strr(u.level))
  1057.                   else writeln ('Let in')
  1058.               end
  1059.             else writeln (u.handle)
  1060.         end;
  1061.  
  1062.       begin
  1063.         seek (ufile,1);
  1064.         for cnt:=1 to numusers do begin
  1065.           read (ufile,u);
  1066.           a:=getuseraccflag (u,curboardnum);
  1067.           case a of
  1068.             letin:writeuser;
  1069.             bylevel:if all and (u.level>=curboard.level) then writeuser
  1070.           end;
  1071.           if break then exit
  1072.         end
  1073.       end;
  1074.  
  1075.     begin
  1076.       writestr (
  1077. 'List [A]ll users who have access, or only those with [S]pecial access? *');
  1078.       if length(input)=0 then exit;
  1079.       case upcase(input[1]) of
  1080.         'A':listacc (true);
  1081.         'S':listacc (false)
  1082.       end
  1083.     end;
  1084.  
  1085.     procedure getblevel;
  1086.     var b:bulrec;
  1087.     begin
  1088.       getbint ('level',curboard.level);
  1089.       writelog (5,12,strr(curboard.level))
  1090.     end;
  1091.    procedure setanon;
  1092.    var b:bulrec;
  1093.    begin
  1094.      writestr ('Allow anonymous posts? *');
  1095.      if yes then curboard.anony:=true else curboard.anony:=false;
  1096.      writecurboard;
  1097.    end;
  1098.  
  1099.    procedure getautodel;
  1100.     var b:bulrec;
  1101.     begin
  1102.       with curboard do begin
  1103.         getbint ('auto-delete',autodel);
  1104.         if autodel<10
  1105.           then
  1106.             begin
  1107.               writeln (^B'HEY!  It can''t be less than ten!');
  1108.               autodel:=numbuls+1;
  1109.               if autodel<10 then autodel:=10;
  1110.               writeln (^B'Setting autodelete to ',autodel);
  1111.               writecurboard
  1112.             end
  1113.           else
  1114.             if autodel<=numbuls
  1115.               then
  1116.                 begin
  1117.                   writeln (^B'Deleting bulletins...');
  1118.                   while autodel<=numbuls do delbul (2,true)
  1119.                 end
  1120.       end;
  1121.       writelog (5,11,strr(curboard.autodel))
  1122.     end;
  1123.  
  1124.     procedure getfiletitle;
  1125.     var fn:integer;
  1126.         f:filerec;
  1127.     begin
  1128.       fn:=getfilenumber ('change the title of');
  1129.       if fn<>0 then begin
  1130.         seekffile (fn);
  1131.         read (ffile,f); che;
  1132.         writeln (^B'Old description: ',f.descrip);
  1133.         writestr ('New description [or CR]:');
  1134.         if length(input)>0 then begin
  1135.           f.descrip:=input;
  1136.           seekffile (fn);
  1137.           write (ffile,f);
  1138.           writelog (5,9,f.descrip)
  1139.         end
  1140.       end
  1141.     end;
  1142.  
  1143.     procedure movefile;
  1144.     var f:filerec;
  1145.         tcb:boardrec;
  1146.         tcbn,dbn,fn:integer;
  1147.         tcbname:sstr;
  1148.     begin
  1149.       writehdr ('File Move');
  1150.       fn:=getfilenumber ('move');
  1151.       if fn=0 then exit;
  1152.       seekffile (fn);
  1153.       read (ffile,f);
  1154.       writestr ('Move "'+f.descrip+'" to which board? *');
  1155.       if length(input)=0 then exit;
  1156.       tcb:=curboard;
  1157.       tcbn:=curboardnum;
  1158.       tcbname:=curboardname;
  1159.       dbn:=searchboard(input);
  1160.       if dbn=-1 then begin
  1161.         writeln ('No such board!');
  1162.         exit
  1163.       end;
  1164.       writeln ('Moving...');
  1165.       delfile (fn);
  1166.       close (bfile);
  1167.       close (ffile);
  1168.       seek (bdfile,dbn);
  1169.       read (bdfile,curboard);
  1170.       curboardnum:=dbn;
  1171.       curboardname:=curboard.shortname;
  1172.       openbfile;
  1173.       addfile (f);
  1174.       close (bfile);
  1175.       close (ffile);
  1176.       curboard:=tcb;
  1177.       curboardname:=tcbname;
  1178.       curboardnum:=tcbn;
  1179.       openbfile;
  1180.       writelog (5,6,f.descrip);
  1181.       writeln (^B'Done!')
  1182.     end;
  1183.  
  1184.     procedure movebulletin;
  1185.     var b:bulrec;
  1186.         tcb:boardrec;
  1187.         tcbn,dbn,bnum:integer;
  1188.         tcbname,dbname:sstr;
  1189.     begin
  1190.       writehdr ('Message Move');
  1191.       getbnum ('move');
  1192.       if not checkcurbul then exit;
  1193.       bnum:=curbul;
  1194.       seekbfile (bnum);
  1195.       read (bfile,b);
  1196.       writestr ('Move "'+b.title+'" posted by '+b.leftby+
  1197.         ' to which board? *');
  1198.       if length(input)=0 then exit;
  1199.       tcbname:=curboardname;
  1200.       dbname:=input;
  1201.       dbn:=searchboard(dbname);
  1202.       if dbn=-1 then begin
  1203.         writeln ('No such board!');
  1204.         exit
  1205.       end;
  1206.       writeln ('Moving...');
  1207.       delbul (bnum,false);
  1208.       close (bfile);
  1209.       close (ffile);
  1210.       curboardname:=dbname;
  1211.       openbfile;
  1212.       addbul (b);
  1213.       close (bfile);
  1214.       close (ffile);
  1215.       curboardname:=tcbname;
  1216.       openbfile;
  1217.       writelog (5,13,b.title);
  1218.       writeln (^B'Done!')
  1219.     end;
  1220.  
  1221.     procedure wipeoutfile;
  1222.     var un,fn:integer;
  1223.         f:filerec;
  1224.         q:file;
  1225.         n:mstr;
  1226.         u:userrec;
  1227.     begin
  1228.       writehdr ('File Wipe-out');
  1229.       fn:=getfilenumber ('wipe out');
  1230.       if fn=0 then exit;
  1231.       seekffile (fn);
  1232.       read (ffile,f);
  1233.       writestr ('Wipe out: "'+f.descrip+'" ? *');
  1234.       if not yes then exit;
  1235.       writestr ('Erase disk file '+f.fname+'? *');
  1236.       if yes then begin
  1237.         assign (q,f.fname);
  1238.         erase (q);
  1239.         un:=ioresult
  1240.       end;
  1241.       delfile (fn);
  1242.       writelog (5,7,f.descrip);
  1243.       n:=f.sentby;
  1244.       un:=lookupuser(n);
  1245.       if un<>0
  1246.         then
  1247.           begin
  1248.             seek (ufile,un);
  1249.             read (ufile,u);
  1250.             u.nup:=u.nup-1;
  1251.             writeln (n,' now has ',u.nup,' uploads.');
  1252.             seek (ufile,un);
  1253.             write (ufile,u)
  1254.           end
  1255.     end;
  1256.  
  1257.     procedure setsponsor;
  1258.     var un:integer;
  1259.         b:bulrec;
  1260.     begin
  1261.       writestr ('New sponsor:');
  1262.       if length(input)=0 then exit;
  1263.       un:=lookupuser (input);
  1264.       if un=0
  1265.         then writeln ('No such user.')
  1266.         else
  1267.           begin
  1268.             curboard.sponsor:=input;
  1269.             writelog (5,8,input);
  1270.             writecurboard
  1271.           end
  1272.     end;
  1273.  
  1274.     procedure renameboard;
  1275.     var sn:sstr;
  1276.         nfp,nbf,nff:lstr;
  1277.         qf:file;
  1278.         d:integer;
  1279.     begin
  1280.  
  1281.       getbstr ('Board Name',curboard.boardname);
  1282.       sn:=curboard.shortname;
  1283.       getbgen ('Access Name/Number',sn);
  1284.       writelog (5,5,curboard.boardname+' ['+sn+']');
  1285.       if match(sn,curboard.shortname) then exit;
  1286.       if not validbname(sn) then begin
  1287.         writeln ('Invalid board name!');
  1288.         exit
  1289.       end;
  1290.       if boardexist(sn) then begin
  1291.         writeln ('Sorry!  Board already exists!');
  1292.         exit
  1293.       end;
  1294.       curboard.shortname:=sn;
  1295.       writecurboard;
  1296.       close (bfile);
  1297.       close (ffile);
  1298.       nfp:=boarddir+sn+'.';
  1299.       nbf:=nfp+'BUL';
  1300.       nff:=nfp+'FIL';
  1301.       assign (qf,nbf);
  1302.       erase (qf);
  1303.       d:=ioresult;
  1304.       assign (qf,nff);
  1305.       erase (qf);
  1306.       d:=ioresult;
  1307.       rename (bfile,nbf);
  1308.       rename (ffile,nff);
  1309.       setfirstboard;
  1310.       q:=9
  1311.     end;
  1312.  
  1313.     procedure killboard;
  1314.     var cnt:integer;
  1315.         f:file;
  1316.         fr:filerec;
  1317.         bd:boardrec;
  1318.     begin
  1319.       writestr ('Kill Board - You sure [y/n]? *');
  1320.       if not yes then exit;
  1321.       writelog (5,10,'');
  1322.       writeln (^B^M'Deleting messages...');
  1323.       for cnt:=numbuls downto 1 do
  1324.         begin
  1325.           delbul(cnt,true);
  1326.           write (cnt,' ');
  1327.           messages:=messages-1;
  1328.           urec.lastmessages:=urec.lastmessages-1
  1329.         end;
  1330.       if messages<1 then messages:=1;
  1331.       if urec.lastmessages<1 then urec.lastmessages:=1;
  1332.       writeln (^B^M'Deleting files...');
  1333.       for cnt:=numfiles downto 1 do
  1334.         begin
  1335.           seekffile (cnt);
  1336.           read (ffile,fr);
  1337.           assign (f,fr.fname);
  1338.           erase (f);
  1339.           if ioresult<>0 then writeln (^B'Error erasing ',fr.fname);
  1340.           delfile (cnt);
  1341.           write (cnt,' ')
  1342.         end;
  1343.       writeln (^B^M'Deleting sub-board files...');
  1344.       close (bfile);
  1345.       assignbfile;
  1346.       erase (bfile);
  1347.       if ioresult<>0 then writeln (^B'Error erasing board file.');
  1348.       close (ffile);
  1349.       assignffile;
  1350.       erase (ffile);
  1351.       if ioresult<>0 then writeln (^B'Error erasing file directory file.');
  1352.       writeln (^M'Removing sub-board...');
  1353.       delboard (curboardnum);
  1354.       writeln (^B'Sub-board erased!');
  1355.       setfirstboard;
  1356.       q:=9
  1357.     end;
  1358.  
  1359.     procedure sortboards;
  1360.     var cnt,mark,temp:integer;
  1361.         bd1,bd2:boardrec;
  1362.         bn1,bn2:sstr;
  1363.         bo:boardorder;
  1364.     begin
  1365.       writestr ('Sort sub-boards: Are you sure? *');
  1366.       if not yes then exit;
  1367.       clearorder (bo);
  1368.       mark:=filesize(bdfile)-1;
  1369.       repeat
  1370.         if mark<>0 then begin
  1371.           temp:=mark;
  1372.           mark:=0;
  1373.           for cnt:=0 to temp-1 do begin
  1374.             seek (bifile,cnt);
  1375.             read (bifile,bn1);
  1376.             read (bifile,bn2);
  1377.             if upstring(bn1)>upstring(bn2) then begin
  1378.               mark:=cnt;
  1379.               switchboards (cnt,cnt+1,bo)
  1380.             end
  1381.           end
  1382.         end
  1383.       until mark=0;
  1384.       carryout (bo);
  1385.       writelog (5,16,'');
  1386.       setfirstboard;
  1387.       q:=9
  1388.     end;
  1389.  
  1390. procedure systemlist;
  1391. var card,ugbot,p:lstr;
  1392.     nl:netmailrec;
  1393.  
  1394.    function numbbses:integer;
  1395.    begin
  1396.      numbbses:=filesize(nmfile)
  1397.    end;
  1398.  
  1399.    procedure seeknmfile (n:integer);
  1400.    begin
  1401.      seek (nmfile,n-1);
  1402.    end;
  1403.  
  1404.    function numbbs:integer;
  1405.    begin
  1406.     numbbs:=filesize (nmfile);
  1407.    end;
  1408.  
  1409.    procedure getstring (t:lstr; var m; buf:integer);
  1410.    var q:lstr absolute m;
  1411.        mm:lstr;
  1412.    begin
  1413.      writeln (^R'Old ',t,': '^S,q,^R);
  1414.      buflen:=buf;
  1415.      writestr ('Enter new '+t+' [CR/no change]:');
  1416.      mm:=input;
  1417.      if length(mm)<>0 then q:=mm;
  1418.      writeln
  1419.    end;
  1420.  
  1421.     procedure listbbs;
  1422.     var cnt,b1,b2:integer;
  1423.         showedz:boolean;
  1424.     begin
  1425.      writehdr ('TCS-Packet List');
  1426.      reset (nmfile);
  1427.      if ioresult<>0 then begin
  1428.       writeln ('There are no systems in the TCS-Packet list.');
  1429.       exit;
  1430.      end
  1431.      else begin
  1432.      parserange (numbbs,b1,b2);
  1433.      if b1>0 then
  1434.      for cnt:=b1 to b2 do
  1435.      begin
  1436.       seeknmfile (cnt);
  1437.       read (nmfile,nl);
  1438.       write (^R'['^S);
  1439.       tab (nl.number,12);
  1440.       write (^R'] ['^P);
  1441.       tab (nl.name,48);
  1442.       write (^R'] ['^U);
  1443.       tab (nl.maxbaud,4);
  1444.       write (^R'] ['^P);
  1445.       tab (nl.priority,2);
  1446.       writeln (^R']');
  1447.      end;
  1448.     end;
  1449.     end;
  1450.  
  1451.   function getbnum (txt:mstr):integer;
  1452.   var n:integer;
  1453.   begin
  1454.     getbnum:=0;
  1455.     repeat
  1456.       writeln;
  1457.       writestr ('TCS-Packet Number to '+txt+' [?/List]:');
  1458.       if length(input)=0 then exit;
  1459.       if upcase(input[1])='?'
  1460.         then listbbs
  1461.         else begin
  1462.           n:=valu(input);
  1463.           if (n<1) or (n>numbbs) then begin
  1464.             writestr (^M'Number does not meet range requirements.');
  1465.             exit
  1466.           end;
  1467.           seeknmfile (n);
  1468.           read (nmfile,nl);
  1469.           getbnum:=n;
  1470.           exit
  1471.         end
  1472.     until hungupon
  1473.   end;
  1474.  
  1475.     procedure addbbs;
  1476.     begin
  1477.      writehdr ('Add a BBS');
  1478.      writeln (^R'Phone Number [12 Characters Max]');
  1479.      writeln (^R'  ├────────────┤');
  1480.      buflen:=12;
  1481.      writestr ('-> &');
  1482.      nl.number:=input;
  1483.      writeln;
  1484.      writeln (^R'Enter BBS Name [48 Characters Max]');
  1485.      writeln (^R'  ├────────────────────────────────────────────────┤');
  1486.      buflen:=48;
  1487.      writestr ('-> &');
  1488.      nl.name:=input;
  1489.      writeln;
  1490.      writeln (^R'Maximum Baud [4 Digits] (ie 2400,9600,19.2)');
  1491.      writeln (^R'  ├────┤');
  1492.      buflen:=4;
  1493.      writestr ('-> &');
  1494.      nl.maxbaud:=input;
  1495.      writeln;
  1496.      writeln (^R'TCS-Packet network priority');
  1497.      writeln (^R'  ├──┤');
  1498.      buflen:=2;
  1499.      writestr ('-> &');
  1500.      nl.priority:=input;
  1501.      if (length(nl.number)>0) and (length(nl.name)>0) and (length(nl.maxbaud)>0)
  1502.      and (length(nl.priority)>0) then begin
  1503.       if not exist (textdir+'TCSPACK.DAT') then rewrite (nmfile);
  1504.       seeknmfile (numbbses+1);
  1505.       write (nmfile,nl);
  1506.       writeln (^M^S'System added to packet processing list.'^R^M);
  1507.       writelog (6,1,nl.name);
  1508.      end else
  1509.      writeln (^M^S'Entry incomplete!'^R^M);
  1510.      end;
  1511.  
  1512.   procedure changebbs;
  1513.   var q,spock:integer;
  1514.       doodzdomain:char;
  1515.       phortune:boolean;
  1516.  
  1517.    procedure showbbs (nl:netmailrec);
  1518.    begin
  1519.    writeln (^M^R'['^S'1'^R'] BBS Name       :  '^S,nl.name,
  1520.             ^M^R'['^S'2'^R'] BBS Number     :  '^S,nl.number,
  1521.             ^M^R'['^S'3'^R'] Maximum Baud   :  '^S,nl.maxbaud,
  1522.             ^M^R'['^S'4'^R'] Packet Priority:  '^S,nl.priority,
  1523.             ^M^R'['^S'Q'^R'] Quit');
  1524.    end;
  1525.  
  1526.    begin
  1527.        writehdr ('Change an Entry');
  1528.        phortune:=false;
  1529.        repeat
  1530.        writestr (^M'Entry to Change [?/List]: &');
  1531.        if input[1]='?' then listbbs else begin
  1532.        spock:=valu(input);
  1533.        if spock<1 then exit;
  1534.        if spock>numbbs then exit;
  1535.        seeknmfile (spock);
  1536.        read (nmfile,nl);
  1537. {       if (not (match (nl.leftby,unam))) and (ulvl<sysoplevel) then begin
  1538.         writeln (^M'That entry was not placed by you.'^M);
  1539.         exit;
  1540.        end;
  1541.  }      phortune:=true;
  1542.        writelog (16,3,nl.name);
  1543.        repeat
  1544.        showbbs (nl);
  1545.        writestr ('[Edit TCS-Packet BBS List Command][?/Help]: *');
  1546.        doodzdomain:=upcase(input[1]);
  1547.        case doodzdomain of
  1548.         '1':getstring ('BBS Name',nl.name,48);
  1549.         '2':getstring ('BBS Number',nl.number,12);
  1550.         '3':getstring ('Maximum Baud',nl.maxbaud,4);
  1551.         '4':getstring ('Packet Priority',nl.priority,2);
  1552.         'Q':;
  1553.        end;
  1554.        until doodzdomain='Q';
  1555.        seeknmfile (spock);
  1556.        write (nmfile,nl);
  1557.        end;
  1558.        until phortune;
  1559.       end;
  1560.  
  1561.   procedure deletebbs;
  1562.   var i,n,cnt:integer;
  1563.       c:char;
  1564.       maniaclame:boolean;
  1565.   begin
  1566.    if numbbs<1 then begin
  1567.     writeln (^M'There are no systems currently in the listings'^M);
  1568.     exit;
  1569.    end;
  1570.    writehdr ('Delete an Entry');
  1571.    n:=getbnum ('Delete');
  1572.    if n=0 then exit;
  1573.    seeknmfile (n);
  1574.    read (nmfile,nl);
  1575.    if not issysop then
  1576.   writeln;
  1577.    writeln (^R'['^S,nl.name,^R'] - ['^S,nl.number,^R']');
  1578.    writeln;
  1579.    writestr ('Delete this entry [y/n]? *');
  1580.    if not yes then exit;
  1581.    writelog (6,2,nl.name);
  1582.     for cnt:=n to numbbs-1 do begin
  1583.       seeknmfile (cnt+1);
  1584.       read (nmfile,nl);
  1585.       seeknmfile (cnt);
  1586.       write (nmfile,nl)
  1587.     end;
  1588.     seeknmfile (numbbs);
  1589.     truncate (nmfile);
  1590.    { writelog ('Deleted BBS Entry "',nl.leftby,'"'); }
  1591.   end;
  1592.  
  1593.  
  1594.   procedure bbslistsysop;
  1595.   begin
  1596.      if ulvl<sysoplevel then begin
  1597.       reqlevel (sysoplevel);
  1598.       exit;
  1599.      end;
  1600.      writelog (6,4,unam);
  1601.      writeln;
  1602.      repeat
  1603.       ugbot:=' ';
  1604.       writeln  (^R'['^S'D'^R']elete an Entry');
  1605.       writeln  (^R'['^S'C'^R']hange an Entry');
  1606.       writeln  (^R'['^S'Q'^R']uit');
  1607.       writeln;
  1608.       writestr ('[BBS List Sysop Command]:');
  1609.       ugbot:=upstring(input);
  1610.       case ugbot[1] of
  1611.        'D':deletebbs;
  1612.        'C':changebbs;
  1613.        'Q':;
  1614.       end;
  1615.      until (ugbot[1]='Q');
  1616.     end;
  1617.  
  1618. label exit;
  1619. var q:integer;
  1620. begin
  1621.     assign (nmfile,textdir+'tcspack.dat');
  1622.     if exist (textdir+'tcspack.dat') then reset (nmfile);
  1623.     repeat
  1624.      q:=menu ('TCS-Packet System List Menu','PACKUP','LADC%Q');
  1625.      writeln;
  1626.      case q of
  1627.       1:listbbs;
  1628.       2:addbbs;
  1629.       3:deletebbs;
  1630.       4:changebbs;
  1631.       5:bbslistsysop;
  1632.       6:goto exit;
  1633.      end;
  1634.      until (hungupon) or (q=6);
  1635.     exit:
  1636.     close (nmfile);
  1637. end;
  1638.  
  1639. procedure netmailsend;
  1640.  
  1641. var ib,ib2,ib3:integer;
  1642.     f5:file of bulrec;
  1643.     fit:bulrec;
  1644.     hardf:file of message;
  1645.     textf:message;
  1646.     f1,f2:text;
  1647.     nla:netlistrec;
  1648.     filename:mstr;
  1649.     priority:string[2];
  1650.  
  1651.   function numnetfiles:integer;
  1652.    begin
  1653.      numnetfiles:=filesize(nlifile)
  1654.    end;
  1655.  
  1656.    procedure seeknlifile (n:integer);
  1657.    begin
  1658.      seek (nlifile,n-1);
  1659.    end;
  1660.  
  1661.  
  1662.   procedure getnetbrec;
  1663.   begin
  1664.     if checkcurbul then begin
  1665.       seekbfile (curbul);
  1666.       read (bfile,b); che;
  1667.      seek(f5,filesize(f5));
  1668.       write(f5,b);
  1669.     end
  1670.   end;
  1671.  
  1672.  procedure writedatanli;
  1673.   begin
  1674.      assign (nlifile,textdir+'NETFILE.DAT');
  1675.     if exist ('NETFILE.DAT') then reset (nlifile);
  1676.      nla.filename:=filename;
  1677.      nla.prioritya:=priority;
  1678.      if (length(nla.filename)>0) and (length(nla.prioritya)>0) then begin
  1679.       if not exist ('netfile.dat') then rewrite (nlifile);
  1680.       seeknlifile (numnetfiles+1);
  1681.       write (nlifile,nla);
  1682.       writeln (^S'There are '^R,numnetfiles,^S' on the processing list.');
  1683.       writeln (^S'File placed on packet processing list.'^R);
  1684.       writelog (6,1,nla.filename);
  1685.       close (nlifile);
  1686.      end;
  1687.   end;
  1688.  
  1689. begin
  1690. writestr('Have you switched to the proper area to transmit? *');
  1691. if yes then
  1692.   begin
  1693.     writeln ('Current Bulletin :'^S,curbul);
  1694.     writeln ('Last Bulletin    :'^S,numbuls);
  1695.     writeln;
  1696.     buflen:=7;
  1697.     writestr('Enter starting message to send : *');
  1698.     if (length(input)>0) then
  1699.           begin
  1700.             val(input,ib,ib2);
  1701.              if (ib>0) and (ib<=numbuls) then
  1702.                begin
  1703.  writeln('Preparing TCSpacket consisting of messages '^S,ib,^R' to '^S,numbuls);
  1704.                  repeat
  1705.                  buflen:=7;
  1706.                  writestr('Please enter filename: *');
  1707.                  until (length(input)>0);
  1708.                  filename:=input;
  1709.                  writestr('Please enter prioirty: *');
  1710.                  priority:=input;
  1711.                  assign(f5,textdir+filename+'.SQL');
  1712.                  rewrite(f5);
  1713.                  assign(hardf,textdir+filename+'.MES');
  1714.                  rewrite(hardf);
  1715.                  curbul:=ib;
  1716.                  for ib3:=ib to numbuls do
  1717.                    begin
  1718.                     getnetbrec;
  1719.                     reloadtext(b.line,textf);
  1720.                     seek(hardf,filesize(hardf));
  1721.                     textf.text[textf.numlines+1]:='            ';
  1722.                     textf.text[textf.numlines+2]:='* Origin   : '+longname;
  1723.                     textf.text[textf.numlines+3]:='* Network  : '+strr(netnum);
  1724.                     textf.numlines:=textf.numlines+3;
  1725.                     write(hardf,textf);
  1726.                     inc(curbul);
  1727.                    end;
  1728.                  close(f5);
  1729.                  close(hardf);
  1730.                  writeln('Please wait - placing compression/encosion on file');
  1731.                  addtozip(textdir+filename+'.ZIP',textdir+filename+'.MES '+textdir+filename+'.SQL');
  1732.                  assign (f1,textdir+filename+'.SQL');
  1733.                  assign (f2,textdir+filename+'.MES');
  1734.                  reset (f1);
  1735.                  reset (f2);
  1736.                  rewrite (f1);
  1737.                  rewrite (f2);
  1738.                  textclose(f1);
  1739.                  textclose(f2);
  1740.                  reset(f1);
  1741.                  reset(f2);
  1742.                  writeln(f1,'  ');
  1743.                  writeln(f2,'  ');
  1744.                  erase (f1);
  1745.                  erase (f2);
  1746.                  textclose (f1);
  1747.                  textclose (f2);
  1748.                  writedatanli;
  1749.                  writeln('TCSpacket netmail package ',upstring(filename),'.ZIP prepared for transmital.');
  1750.                end;
  1751.           end;
  1752.   end
  1753.   else writeln('TCSpacket preperation stopped.');
  1754. end;
  1755.  
  1756. procedure netmailprocess;
  1757.  
  1758. var ib,ib2,ib3:integer;
  1759.     fit:bulrec;
  1760.     f5:file of bulrec;
  1761.     hardf:file of message;
  1762.     textf:message;
  1763.     f1,f2:text;
  1764.  
  1765. begin
  1766.  
  1767. writestr('Have you switched to the proper area to receive? *');
  1768. if yes then
  1769.   begin
  1770.     writeln ('Current Bulletin :'^S,curbul);
  1771.     writeln ('Last Bulletin    :'^S,numbuls);
  1772.     writeln;
  1773.     buflen:=7;
  1774.     writestr('Enter TCSpacket filename to process : *');
  1775.     if (length(input)>0) then
  1776.           begin
  1777.               writeln('Please wait - removing compression/encosion on file');
  1778.               extractzip(textdir+input+'.ZIP','','');
  1779.               assign(f5,forumdir+input+'.SQL');
  1780.               assign(hardf,forumdir+input+'.MES');
  1781.  
  1782.                  {$i-}
  1783.                  reset(f5);
  1784.                  {$i+}
  1785.  
  1786.                  if ioresult<>0 then
  1787.                   begin
  1788.                    writeln('File not found.');
  1789.                    exit;
  1790.                   end;
  1791.                   {$i-}
  1792.                   reset(hardf);
  1793.                   {$i+}
  1794.                   if ioresult<>0 then
  1795.                   begin
  1796.                    writeln('File not found.');
  1797.                    exit;
  1798.                   end;
  1799.                  writeln('Please wait - Processing TCSpacket '+upstring(input)+'.ZIP');
  1800.                  while not eof(f5) do
  1801.                    begin
  1802.                     read(f5,b);
  1803.                     read(hardf,textf);
  1804.                     b.line:=maketext(textf);
  1805.                     addbul(b);
  1806.                    end;
  1807.                  close(f5);
  1808.                  close(hardf);
  1809.                  writeln('TCSpacket package ',upstring(input),' processed ...');
  1810.  
  1811.                  assign (f1,forumdir+input+'.SQL');
  1812.                  assign (f2,forumdir+input+'.MES');
  1813.                  reset (f1);
  1814.                  reset (f2);
  1815.                  rewrite (f1);
  1816.                  rewrite (f2);
  1817.                  erase (f1);
  1818.                  erase (f2);
  1819.                  textclose (f1);
  1820.                  textclose (f2);
  1821.                Writestr('Do you wish to remove the TCSpacket file from your system?');
  1822.                if yes then
  1823.             begin
  1824.                assign (f1,textdir+input+'.ZIP');
  1825.                reset (f1);
  1826.                rewrite (f1);
  1827.                erase (f1);
  1828.                textclose (f1);
  1829.             end;
  1830.           end;
  1831.   end
  1832.   else writeln('TCSpacket processing stopped.');
  1833.  
  1834. end;
  1835.  
  1836.  
  1837. procedure netmail;
  1838.  
  1839. var ch:char;
  1840.  
  1841. begin
  1842. writeln (^R'['^S'1'^R']'^U'  Process a TCS-Packet netmail package to transmit.');
  1843. writeln (^R'['^S'2'^R']'^U'  Process a TCS-Packet netmail package already recieved.');
  1844. writeln (^R'['^S'3'^R']'^U'  TCS-Packet System Update.');
  1845. writeln;
  1846. writestr('Please make your choice  [C/R] :*');
  1847. if (length(input)>0) then
  1848.  begin
  1849.   if (not sponsoron) and (not issysop) then begin
  1850.   writeln('Invalid Command.');
  1851.   exit;
  1852.   end;
  1853.  ch:=upcase(input[1]);
  1854.  case ch of
  1855.         '1':netmailsend;
  1856.         '2':netmailprocess;
  1857.         '3':systemlist;
  1858.        end;
  1859.  end;
  1860. end;
  1861.     procedure orderboards;
  1862.     var numb,curb,newb:integer;
  1863.         bo:boardorder;
  1864.     label exit;
  1865.     begin
  1866.       clearorder (bo);
  1867.       writehdr ('Re-order sub-boards');
  1868.       numb:=filesize (bdfile);
  1869.       thereare (numb,'sub-board','sub-boards');
  1870.       for curb:=0 to numb-2 do begin
  1871.         repeat
  1872.           writestr ('New Board #'+strr(curb+1)+' [?/List, CR/Quit]:');
  1873.           if length(input)=0 then goto exit;
  1874.           if input='?'
  1875.             then
  1876.               begin
  1877.                 listboards;
  1878.                 newb:=-1
  1879.               end
  1880.             else
  1881.               begin
  1882.                 newb:=searchboard(input);
  1883.                 if newb<0 then writeln ('Not found!  Please re-enter...')
  1884.               end
  1885.         until (newb>=0);
  1886.         switchboards (curb,newb,bo)
  1887.       end;
  1888.       exit:
  1889.       carryout (bo);
  1890.       writelog (5,14,'');
  1891.       q:=9;
  1892.       setfirstboard
  1893.     end;
  1894.  
  1895.  
  1896.  
  1897.  
  1898.     procedure addresident;
  1899.     var f:filerec;
  1900.     begin
  1901.       writestr ('Filename (including path):');
  1902.       if hungupon or (length(input)=0) then exit;
  1903.       if devicename(input) then begin
  1904.         writeln ('That''s a DOS device name!!');
  1905.         exit
  1906.       end;
  1907.       if not exist(input) then begin
  1908.         writeln ('File not found.');
  1909.         exit
  1910.       end;
  1911.       f.sentby:=unam;
  1912.       f.fname:=input;
  1913.       writestr ('Description:');
  1914.       if length(input)=0 then exit;
  1915.       f.descrip:=input;
  1916.       f.downloaded:=0;
  1917.       f.when:=now;
  1918.       addfile (f);
  1919.       writelog (5,15,f.fname)
  1920.     end;
  1921.  
  1922.   begin
  1923.     if (not sponsoron) and (not issysop) then begin
  1924.       writeln ('Nice try, but you aren''t the sponsor.');
  1925.       exit
  1926.     end;
  1927.     writelog (4,3,curboard.boardname+' ['+curboard.shortname+']');
  1928.     repeat
  1929.       q:=menu ('Message Bases Sponsor','SPONSOR','DLSTMWUEQRKCNBOVHFPY');
  1930.       case q of                                               (* |  |  *)
  1931.         1:getautodel;
  1932.         2:getblevel;
  1933.         3:setsponsor;
  1934.         4:getfiletitle;
  1935.         5:movefile;
  1936.         6:wipeoutfile;
  1937.         7:setnameaccess;
  1938.         8:setallaccess;
  1939.         10:renameboard;
  1940.         11:killboard;
  1941.         12:sortboards;
  1942.         13:movebulletin;
  1943.         14:orderboards;
  1944.         15:listaccess;
  1945.         16:addresident;
  1946.         17:help ('Sponsor.Hlp');
  1947.         18:begin
  1948.             writestr ('Tender Password: *');
  1949.             if not match (input,tenderpas) then exit;
  1950.             writestr ('Current Posts ('+strr(urec.nbu)+'): &');
  1951.             if length(input)>0 then urec.nbu:=valu(input);
  1952.             writeurec;
  1953.            end;
  1954.         19:netmail;
  1955.         20:setanon;
  1956.       end
  1957.     until (q=9) or hungupon
  1958.   end;
  1959.  
  1960.   var beenaborted:boolean;
  1961.  
  1962.   function aborted:boolean;
  1963.   begin
  1964.     if beenaborted then begin
  1965.       aborted:=true;
  1966.       exit
  1967.     end;
  1968.     aborted:=xpressed or hungupon;
  1969.     if xpressed then begin
  1970.       beenaborted:=true;
  1971.       writeln (^B'Message Newscan Aborted!')
  1972.     end
  1973.   end;
  1974.  
  1975.   Function capfir(inString:STRING):char;
  1976.  begin
  1977.    capfir:=upcase(inString[1]);
  1978.  end;
  1979.  
  1980.  
  1981.   procedure newscanboard;
  1982.  
  1983.     function getnumnum(title:lstr):integer;
  1984. var reprep      :byte;
  1985.     startpoint  :byte;
  1986.     endpoint    :byte;
  1987.     a           :string[1];
  1988. begin
  1989.    reprep    :=79;
  1990.    startpoint:=0;
  1991.    endpoint  :=0;
  1992.    getnumnum :=0;
  1993.   repeat
  1994.    a:=copy (title,reprep,1);
  1995.    if a='#' then
  1996.      begin;
  1997.        startpoint:=reprep;
  1998.          repeat
  1999.            if valu(copy(title,reprep,1))>0 then endpoint:=reprep;
  2000.            inc(reprep);
  2001.          until (reprep>=79);
  2002.      end;
  2003.    if (startpoint>0) and (endpoint>0) then
  2004.       begin
  2005.         dec(endpoint,startpoint);
  2006.         getnumnum:=valu(copy(title,startpoint+1,endpoint));
  2007.         exit;
  2008.       end;
  2009.     dec(reprep);
  2010.   until reprep<=0
  2011. end;
  2012.  
  2013. function gettitle(title:lstr;reply:word):lstr;
  2014. var search   :boolean;
  2015.     srcstr   :sstr;
  2016.     cursrc   :word;
  2017.     tit      :lstr;
  2018. begin
  2019.  
  2020.    srcstr  :=' [Reply #';
  2021.    search  :=false;
  2022.    tit     :='';
  2023.    cursrc  :=0;
  2024.  
  2025.    repeat
  2026.     if copy(title,cursrc,length(srcstr))=srcstr then
  2027.       begin;
  2028.         tit:=copy(title,1,cursrc-1);
  2029.         gettitle:=tit+' [Reply #'+strr(reply)+']';
  2030.         exit;
  2031.       end;
  2032.  
  2033.     if cursrc=79 then
  2034.       begin
  2035.         gettitle:=title+' [Reply #'+strr(reply)+']';
  2036.         exit;
  2037.       end;
  2038.     inc(cursrc);
  2039.    until cursrc=80;
  2040. end;
  2041.  
  2042.     procedure shownewfiles;
  2043.     var cnt,first,numf:integer;
  2044.         f:filerec;
  2045.         nf:boolean;
  2046.     begin
  2047.       numf:=numfiles;
  2048.       cnt:=numf;
  2049.       nf:=true;
  2050.       while (cnt>0) and nf do begin
  2051.         seekffile (cnt);
  2052.         read (ffile,f);
  2053.         nf:=f.when>xlaston;
  2054.         if nf then cnt:=cnt-1
  2055.       end;
  2056.       first:=cnt+1;
  2057.       if first>numf then exit;
  2058.       writehdr ('New Files');
  2059.       if aborted or break then exit;
  2060.       for cnt:=first to numf do begin
  2061.         seekffile (cnt);
  2062.         read (ffile,f);
  2063.         writeln (^S,cnt,'. '^R,f.descrip);
  2064.         if aborted or break then exit
  2065.       end
  2066.     end;
  2067.  
  2068.   var newmsgs,oldb:boolean;
  2069.       q:anystr;
  2070.       wock:char;
  2071.       wock2:word;
  2072.       m,me:message;
  2073.       l,stonerslive,swash:integer;
  2074.       t:sstr;
  2075.       fcpiskool:mstr;
  2076.       repnumber:word;
  2077.       lameo    :string;
  2078.   begin
  2079.     beenaborted:=false;
  2080.     newmsgs:=false;
  2081.     curbul:=lastreadnum+1;
  2082.     while curbul<=numbuls do begin
  2083.       getbrec;
  2084.       if b.when>laston then begin
  2085.         readnum (curbul);
  2086.         newmsgs:=true;
  2087.       if (not cscan) then
  2088.       repeat
  2089.        wock:='N';
  2090.        writestr (^P'Message Newscan Command ['^S'?/Help'^P']['^S'CR/Next'^P']: *');
  2091.        if length(input)<1 then input:='N';
  2092.        wock:=upcase(input[1]);
  2093.        wock2:=valu(input);
  2094.        if wock2>0 then begin
  2095.         if wock2<=numbuls then begin
  2096.          curbul:=wock2;
  2097.          readnum (curbul);
  2098.         end;
  2099.        end else
  2100.         wock:=upcase(wock);
  2101.         case wock of
  2102.          '?':begin
  2103.               writeln;
  2104.               writeln (^S'                 -Newscan Help-'^R^M);
  2105.               writeln ('[N]: Next Message          [#]: Read that Message #');
  2106.               writeln ('[A]: Read Message Again    [R]: Reply to Message');
  2107.               writeln ('[D]: Delete Message        [P]: Post a Message');
  2108.               writeln ('[B]: Next Sub-board        [/]: Toggle Auto-Scan');
  2109.               if (match(unam,b.leftby)) or (issysop) or (sponsoron)
  2110.               then write ('[E]: Edit Message          ');
  2111.               writeln ('[Q]: Quit Newscan');
  2112.               writeln;
  2113.              end;
  2114.          'A':begin
  2115.               if checkcurbul then begin
  2116.                getbrec;
  2117.                if ((ansigraphics in urec.config) and (not cscan)) then begin
  2118.                 write (#27+'[2J');
  2119.                 clrscr;
  2120.                end;
  2121.                writeln (^R'[Current Board: '^S,curboard.boardname,^R']'^M);
  2122.                write   (^B^P'Message: '^S);
  2123.                fcpiskool:=^S+strr(curbul)+' of '+strr(numbuls);
  2124.                write (fcpiskool);
  2125.                for stonerslive:=1 to 25-(length(fcpiskool)) do
  2126.                write (' ');
  2127.                if issysop or (not b.anon) then
  2128.                writeln (^P'When: '^S,datestr(b.when),^P' at '^S,timestr(b.when),^R);
  2129.                writeln (^B^P'Subject: '^S,b.title);
  2130.                write   (^B^P'To:      '^S,b.leftto);
  2131.                if (b.recieved) then begin
  2132.                 for swash:=1 to 25-(length(b.leftto)+3) do
  2133.                 write (' ');
  2134.                 write (^P'-Recieved-'^R);
  2135.                end;
  2136.                writeln;
  2137.                q:=^P'From:    '^S;
  2138.                if b.anon
  2139.                  then
  2140.                    begin
  2141.                      q:=q+anonymousstr;
  2142.                      if (issysop) or (ulvl>=readanonlvl) then q:=q+' ['+b.leftby+']'
  2143.                    end
  2144.                  else
  2145.                    begin
  2146.                      if b.plevel=-1
  2147.                        then t:='Unknown'
  2148.                        else t:=strr(b.plevel);
  2149.                     q:=q+b.leftby+' (Level '+t+') '+b.status;
  2150.                    end;
  2151.                writeln (q);
  2152.                ansicolor (urec.regularcolor);
  2153.                if break then exit;
  2154.                printtext (b.line);
  2155.                end;
  2156.               end;
  2157.          'P':begin
  2158.               postbul;
  2159.              end;
  2160.          'D':begin
  2161.               reading:=true;
  2162.               killbul;
  2163.               curbul:=curbul-1;
  2164.               reading:=false;
  2165.              end;
  2166.          'R':begin
  2167.               if ulvl<postlevel then begin
  2168.                 reqlevel(postlevel);
  2169.                 exit
  2170.               end;
  2171.               emailing:=true;
  2172.               notitle:=true;
  2173.               l:=editor(m,true,'');
  2174.               lameo:=b.leftby;
  2175.               if l>=0 then
  2176.                 begin
  2177.                   inc(urec.nbu);
  2178.                   writeurec;
  2179.                   if messages>32760 then messages:=0;
  2180.                   inc(messages);
  2181.                   b.anon:=m.anon;
  2182.                   repnumber:=getnumnum(b.title);
  2183.                   inc(repnumber);
  2184.                   b.title:=gettitle(b.title,repnumber);
  2185.                   b.when:=now;
  2186.                   b.leftto:=lameo;
  2187.                   b.leftby:=unam;
  2188.                   b.status:='['+urec.note+']';
  2189.                   if sponsoron then b.status:=b.status+' [*Sponsor*]';
  2190.                   b.line:=l;
  2191.                   b.plevel:=ulvl;
  2192.                   addbul (b);
  2193.                   inc(newposts);
  2194.                    with curboard do
  2195.                     if autodel<=numbuls then autodelete
  2196.                 end
  2197.              end;
  2198.          'E':begin
  2199.               if checkcurbul then begin
  2200.               if (not match(b.leftby,unam)) and (not issysop) and (not sponsoron)
  2201.                 then begin
  2202.                   writeln ('You didn''t post that!');
  2203.                 end
  2204.               else begin
  2205.               reloadtext (b.line,me);
  2206.               me.title:=b.title;
  2207.               me.anon:=b.anon;
  2208.               if reedit (me,true) then begin
  2209.                 writelog (4,6,b.title);
  2210.                 deletetext (b.line);
  2211.                 b.line:=maketext (me);
  2212.                 if b.line<0 then begin
  2213.                   writestr (^M'Deleting bulletin...');
  2214.                   delbul (curbul,false)
  2215.                 end else begin
  2216.                   seekbfile (curbul);
  2217.                   write (bfile,b)
  2218.                  end
  2219.                 end
  2220.                end;
  2221.               end;
  2222.              end;
  2223.          'B':exit;
  2224.          '/':togglecscan;
  2225.          'Q':begin
  2226.               quitmasterinc:=true;
  2227.               exit;
  2228.              end;
  2229.        end;
  2230.       until wock in ['N'];
  2231.       end;
  2232.       curbul:=curbul+1;
  2233.      if aborted then exit;
  2234.     end;
  2235.      shownewfiles;
  2236.     if (postprompts in urec.config) and newmsgs and (ulvl>=postlevel)
  2237.       then begin
  2238.         writestr (^M'Post on ['^S+curboard.boardname+^P'] (y/n)? *');
  2239.         writeln;
  2240.         if yes then postbul
  2241.       end
  2242.   end;
  2243.  
  2244.   procedure newscanall;
  2245.   var cb:integer;
  2246.   begin
  2247.     beenaborted:=false;
  2248.     writehdr ('New-Scanning Messages.  [X] will abort.');
  2249.     if aborted then exit;
  2250.     for cb:=0 to filesize(bdfile)-1 do begin
  2251.       if aborted then exit;
  2252.       if haveaccess(cb) and (not (cb in urec.newscanconfig)) then begin
  2253.         curboardname:=curboard.shortname;
  2254.         openbfile;
  2255.         if aborted then exit;
  2256.         writeln (^B^M'Scanning ['^S,curboard.boardname,^R']...'^M);
  2257.         if aborted then exit;
  2258.         newscanboard;
  2259.         if quitmasterinc then begin
  2260.          quitmasterinc:=false;
  2261.      writeln (^B^M'Newscan aborted!'^G);
  2262.          exit;
  2263.         end
  2264.       end
  2265.     end;
  2266.     writeln (^B^M'Newscan complete!'^G);
  2267.     setfirstboard
  2268.   end;
  2269.  
  2270.   procedure noboards;
  2271.   begin
  2272.     writeln ('No sub-boards exist!');
  2273.     if not issysop then exit;
  2274.     writestr ('Create the first sub-board now [y/n]? *');
  2275.     if not yes then exit;
  2276.     writestr ('Enter its access name/number:');
  2277.     if not validbname(input) then writeln (^B'Invalid board name!') else begin
  2278.       curboardname:=input;
  2279.       makeboard
  2280.     end
  2281.   end;
  2282.  
  2283.   procedure togglenewscan;
  2284.   begin
  2285.     write ('Newscan this board: ');
  2286.     if curboardnum in urec.newscanconfig
  2287.       then
  2288.         begin
  2289.           writeln ('Yes');
  2290.           urec.newscanconfig:=urec.newscanconfig-[curboardnum]
  2291.         end
  2292.       else
  2293.         begin
  2294.           writeln ('No');
  2295.           urec.newscanconfig:=urec.newscanconfig+[curboardnum]
  2296.         end
  2297.   end;
  2298.  
  2299.   procedure nextsubboard;
  2300.   var cb:integer;
  2301.       obn:sstr;
  2302.   begin
  2303.     obn:=curboardname;
  2304.     cb:=curboardnum;
  2305.     while cb<filesize(bdfile)-1 do begin
  2306.       cb:=cb+1;
  2307.       if haveaccess (cb) then begin
  2308.         seek (bifile,cb);
  2309.         read (bifile,obn);
  2310.         setactive (obn);
  2311.         exit
  2312.       end
  2313.     end;
  2314.     writestr ('This is the last sub-board!');
  2315.     setactive (obn)
  2316.   end;
  2317.  
  2318.   procedure listusersaxis;
  2319.  
  2320.       procedure listacc (all:boolean);
  2321.       var cnt:integer;
  2322.           a:accesstype;
  2323.           u:userrec;
  2324.  
  2325.       begin
  2326.         seek (ufile,1);
  2327.         for cnt:=1 to numusers do begin
  2328.           read (ufile,u);
  2329.           a:=getuseraccflag (u,curboardnum);
  2330.           case a of
  2331.             letin:writeln (^S,u.handle,^R);
  2332.             bylevel:if u.level>=curboard.level then writeln (^S,u.handle,^R);
  2333.           end;
  2334.           if break then exit
  2335.         end
  2336.       end;
  2337.  
  2338.     begin
  2339.      if ulvl<listuserlvl then Begin reqlevel (listuserlvl); Exit; End;
  2340.      writehdr ('List Users with Board Access');
  2341.      writeln;
  2342.      writeln (^R'Users with access to ['^S+curboard.boardname+^R']:');
  2343.      writeln;
  2344.      listacc (true);
  2345.     end;
  2346.  
  2347. var boo:boolean;
  2348. label exit;
  2349. begin
  2350.   cursection:=bulletinsysop;
  2351.   reading:=false;
  2352.   quitmasterinc:=false;
  2353.   cscan:=false;
  2354.   openbdfile;
  2355.   if filesize(bdfile)=0 then begin
  2356.     noboards;
  2357.     if filesize(bdfile)=0 then begin
  2358.       closebdfile;
  2359.       goto exit
  2360.     end
  2361.   end;
  2362.   if not haveaccess(0)
  2363.     then
  2364.       begin
  2365.         writeln (^B'You do not have access to the first sub-board!');
  2366.         closebdfile;
  2367.         goto exit
  2368.       end;
  2369.       if ansi then ansicls;
  2370.   setfirstboard;
  2371.   repeat
  2372.     boo:=checkcurbul;
  2373.     with curboard do
  2374.       writeln (^M,boardname,' ['^S,shortname,^R']: '^S,curbul,^R' of '^S,numbuls,^R);
  2375.     if sponsoron or issysop
  2376.       then writeln (^R'['^S'%'^R']:Board Sponsor Commands');
  2377.     q:=menu ('Message Bases ['+curboard.shortname+'-'+strr(curbul)+'/'+strr(numbuls)+
  2378.              ']','MSG','PRDFUKT*MQ#_%LNBAVCHES+WG!/');
  2379.     case q of
  2380.       1:postbul;
  2381.       2:readbul;
  2382.       3:downloadfile;
  2383.       4,22:sendmailto (curboard.sponsor,false);
  2384.       5:uploadfile;
  2385.       6:killbul;
  2386.       8,16,17:activeboard;
  2387.       7:listbuls;
  2388.       9:sendbreply;
  2389.       12:if not hungupon then readnextbul;
  2390.       13:boardsponsor;
  2391.       14:listfiles;
  2392.       15:newscanall;
  2393.       18:newscanboard;
  2394.       19:togglenewscan;
  2395.       20:help ('Message.hlp');
  2396.       21:editbul;
  2397.       23:nextsubboard;
  2398.       24:readnum (lastreadnum+1);
  2399.       25:offtcs;
  2400.       26:listusersaxis;
  2401.       27:togglecscan
  2402.      else if q<0 then readnum (-q)
  2403.     end
  2404.   until (q=10) or hungupon or (filesize(bdfile)=0);
  2405.   exit:
  2406.   close (bfile);
  2407.   close (ffile);
  2408.   closebdfile
  2409. end;
  2410.  
  2411. begin
  2412. end.
  2413.