home *** CD-ROM | disk | FTP | other *** search
/ Jason Aller Floppy Collection / 341.img / TCS161S.ZIP / SUBS2.PAS < prev    next >
Pascal/Delphi Source File  |  1989-12-06  |  45KB  |  1,924 lines

  1. {$R-,S-,I-,D-,F+,V-,B-,N-,L+ }
  2. {$M 65500,0,0 }
  3.  
  4. unit subs2;
  5.  
  6. { $define testingdevices}   { Activate this define for test mode }
  7.  
  8. interface
  9.  
  10. uses printer,dos,crt,overlay,gentypes,configrt,gensubs,subs1,windows,modem,
  11.      statret,chatstuf,flags,userret,qwik;
  12.  
  13. procedure clearscr;
  14. procedure beepbeep;
  15. procedure summonbeep;
  16. procedure abortttfile (er:integer);
  17. procedure openttfile;
  18. procedure writecon (k:char);
  19. procedure toggleavail;
  20. {procedure domacro (sussuh:anystr);}
  21. function charready:boolean;
  22. function readchar:char;
  23. function waitforchar:char;
  24. procedure clearchain;
  25. function charpressed (k:char):boolean;  { TRUE if K is in typeahead }
  26. procedure addtochain (l:lstr);
  27. procedure directoutchar (k:char);
  28. procedure handleincoming;
  29. procedure writechar (k:char);
  30. {F+}
  31.       function opendevice (var t:textrec):integer;
  32.       function closedevice (var t:textrec):integer;
  33.       function cleardevice (var t:textrec):integer;
  34.       function ignorecommand (var t:textrec):integer;
  35.       function directoutchars (var t:textrec):integer;
  36.       function writechars (var t:textrec):integer;
  37.       function directinchars (var t:textrec):integer;
  38.       function readcharfunc (var t:textrec):integer;
  39. {F-}
  40. function getinputchar:char;
  41. procedure getstr (mode:integer);
  42. procedure writestr (s:anystr);
  43. procedure printxy (x,y:integer;str:anystr);
  44. procedure cls;
  45. procedure writehdr (q:anystr);
  46. function issysop:boolean;
  47. function islz:boolean;
  48. procedure reqlevel (l:integer);
  49. procedure printfile (fn:lstr);
  50. procedure print_the_stats (fn:lstr);
  51. procedure show_all_info (fn:lstr;dernier:mstr;nombre:integer);
  52. procedure printtexttopoint (var tf:text);
  53. procedure skiptopoint (var tf:text);
  54. function minstr (blocks:integer):sstr;
  55. procedure parserange (numents:integer; var f,l:integer);
  56. function menutype:integer;
  57. function menu (mname:mstr; mfn:sstr; choices:anystr):integer;
  58. function checkpassword (var u:userrec):boolean;
  59. function getpassword:boolean;
  60. procedure getacflag (var ac:accesstype; var tex:mstr);
  61. procedure calcqr;
  62. procedure overlayerror;
  63. function parsedate (date:anystr):lstr;
  64. function ansi:boolean;
  65. function ascii:boolean;
  66. procedure setmenutype;
  67. procedure movexy (x,y:integer);
  68. procedure ansicls;
  69. procedure idiot;
  70.  
  71. implementation
  72.  
  73.   procedure clearscr;
  74.   begin
  75.     write (direct,#27'[2J')
  76.   end;
  77.  
  78. procedure beepbeep;
  79. begin
  80.   nosound;
  81.   sound (200);
  82.   delay (20);
  83.   nosound
  84. end;
  85.  
  86. procedure summonbeep;
  87. var a,b,c:integer;
  88.  
  89. Begin
  90. Nosound;
  91. c:=0;
  92. Randomize;
  93. c:=c+1;
  94.   For a:=100 to 125 do Begin
  95.   b:=Random(200);
  96.    Sound (b+a);
  97.    Delay(3);
  98.    end;
  99.  
  100.   For a:=50 downto 25 do begin
  101.   b:=Random(20);
  102.    Sound (b * a);
  103.    Delay(3);
  104.    end;
  105.  nosound
  106. end;
  107.  
  108. procedure abortttfile (er:integer);
  109. var n:integer;
  110. begin
  111.   specialmsg ('<Texttrap error '+strr(er)+'>');
  112.   texttrap:=false;
  113.   textclose (ttfile);
  114.   n:=ioresult
  115. end;
  116.  
  117. procedure openttfile;
  118. var n:integer;
  119. begin
  120.   appendfile ('Texttrap',ttfile);
  121.   n:=ioresult;
  122.   if n=0
  123.     then texttrap:=true
  124.     else abortttfile (n)
  125. end;
  126.  
  127. function scramble (s:char):char;
  128. var f:text;
  129.     x,y:char;
  130.     z:integer;
  131. begin
  132.  scramble:=s;
  133.  if noscramble then exit;
  134.  if not scrambled then exit;
  135.  if not exist (forumdir+'Scramble.Dat') then exit;
  136.  if not (ord(s) in [65..90,97..122]) then exit;
  137.  assign (f,forumdir+'Scramble.Dat');
  138.  reset (f);
  139.  for z:=1 to ord(s) do
  140.  read (f,x);
  141.  scramble:=x;
  142.  close (f);
  143. end;
  144.  
  145. procedure overridescramble;
  146. begin
  147.  if scrambled then begin
  148.   scrambled:=false;
  149.  end else
  150.  if not scrambled then begin
  151.   scrambled:=true;
  152.  end;
  153.  textcolor (12);
  154.  writeln (usr);
  155.  writeln (usr);
  156.  beepbeep;
  157.  writeln (usr,'┌─────────────────────────────┐');
  158.  write (usr,'│ ** ');
  159.  textcolor (9);
  160.  write (usr,'Data Scramble Override!!');
  161.  textcolor (12);
  162.  writeln (usr,' │');
  163.  write (usr,'│ ** ');
  164.  textcolor (10);
  165.  write (usr,'Data Scramble is now:');
  166.  textcolor (11);
  167.  if scrambled then write (usr,'ON  ') else
  168.   if not scrambled then write (usr,'OFF ');
  169.  textcolor (12);
  170.  writeln (usr,'│');
  171.  writeln (usr,'└─────────────────────────────┘');
  172.  writeln (usr);
  173.  writeln (usr);
  174.  ansicolor (urec.regularcolor);
  175. end;
  176.  
  177.  
  178. procedure togglescreenoutput;
  179. begin
  180.  if screenoutput then
  181.  screenoutput:=false else
  182.  screenoutput:=true;
  183. end;
  184.  
  185. procedure writecon (k:char);
  186. var r:registers;
  187.     kk:char;
  188. begin
  189.   if k=^J
  190.     then write (usr,k)
  191.     else
  192.       begin
  193.       { if scrambled then kk:=scramble (k)
  194.         else } kk:=k;
  195.         r.dl:=ord(kk);
  196.         r.ah:=2;
  197.         intr($21,r)
  198.       end
  199. end;
  200.  
  201. procedure toggleavail;
  202. begin
  203.   if sysopavail=Notavailable
  204.     then sysopavail:=available
  205.     else sysopavail:=succ(sysopavail)
  206. end;
  207.  
  208. procedure domacro (sussuh:anystr); forward;
  209.  
  210. function charready:boolean;
  211. var k:char;
  212. begin
  213.   if modeminlock then while numchars>0 do k:=getchar;
  214.   if hungupon or keyhit
  215.     then charready:=true
  216.     else if online
  217.       then charready:=(not modeminlock) and (numchars>0)
  218.       else charready:=false
  219. end;
  220.  
  221. function readchar:char;
  222.  
  223.   procedure toggletempsysop;
  224.   begin
  225.     if tempsysop
  226.       then ulvl:=regularlevel
  227.       else
  228.         begin
  229.           regularlevel:=ulvl;
  230.           ulvl:=sysoplevel
  231.         end;
  232.     tempsysop:=not tempsysop
  233.   end;
  234.  
  235.   procedure togviewstats;
  236.   begin
  237.     if splitmode
  238.       then unsplit
  239.       else
  240.         begin
  241.           splitscreen (14);
  242.           top;
  243.           clrscr;
  244.           write (usr,'[Level]:          ',urec.level,
  245.                  ^M^J'[File Level]:     ',urec.udlevel,
  246.                  ^M^J'[File Points]:    ',urec.udpoints,
  247.                  ^M^J'[User Note]:      ',urec.note,
  248.                  ^M^J'[# Downloads]:    ',urec.downloads,
  249.                  ^M^J'[# Uploads]:      ',urec.uploads,
  250.                  ^M^J'[# of Posts]:     ',urec.nbu,
  251.                  ^M^J'[G-File Ups]:     ',urec.nup,
  252.                  ^M^J'[G-File Downs]:   ',urec.ndn,
  253.                  ^M^J'[Total Time]:     ',urec.totaltime:0:0,
  254.                  ^M^J'[# of Calls]:     ',urec.numon);
  255.           bottom
  256.         end;
  257.   end;
  258.  
  259.   procedure showhelp;
  260.   begin
  261.     if splitmode
  262.       then unsplit
  263.       else begin
  264.         splitscreen (12);
  265.         top;
  266.         clrscr;
  267.         write (usr,
  268. 'Chat with user: <F1>                 Sysop Commands: <F2>'^M^J,
  269. 'Sysop gets the system next: <F7>     Lock the timer: <F8>'^M^J,
  270. 'Lock out all modem input: <F9>       Lock all Modem output: <F10>'^M^J,
  271. 'Chat availabily toggle: <Alt-A>      Grant temporary sysop powers: <Alt-T>'^M^J,
  272. 'Give User 1 min. time: <Right-Arrow> Take away 1 minute time: <Left-Arrow>'^M^J,
  273. 'Take away all time: <Alt-K>          Refresh the Bottom line: <Alt-B>'^M^J,
  274. 'Toggle printer echo: <Ctrl-PrtScr>   Toggle Text Trap: <Alt-E>'^M^J,
  275. 'View users Status: <Alt-V>           Sysop Macros #1-10: <Alt-F1>-<Alt-F10>'^M^J,
  276. 'Override Data Scrambling: <Alt-O>    ');
  277.     end;
  278.   end;
  279.  
  280.   procedure toggletexttrap;
  281.   var n:integer;
  282.   begin
  283.     if texttrap
  284.       then
  285.         begin
  286.           textclose (ttfile);
  287.           n:=ioresult;
  288.           if n<>0 then abortttfile (n);
  289.           texttrap:=false
  290.         end
  291.       else openttfile
  292.   end;
  293.  
  294. procedure printsysopmacro (n:integer);
  295. begin
  296.  case n of
  297.   1:domacro (sysopmacro1);
  298.   2:domacro (sysopmacro2);
  299.   3:domacro (sysopmacro3);
  300.   4:domacro (sysopmacro4);
  301.   5:domacro (sysopmacro5);
  302.   6:domacro (sysopmacro6);
  303.   7:domacro (sysopmacro7);
  304.   8:domacro (sysopmacro8);
  305.   9:domacro (sysopmacro9);
  306.  10:domacro (sysopmacro10);
  307.  end;
  308. end;
  309.  
  310.  
  311. var k:char;
  312.     ret:char;
  313.     dorefresh:boolean;
  314.     iamlaym:byte;
  315.     i:integer;
  316. begin
  317.   requestchat:=false;
  318.   requestcom:=false;
  319.   reqspecial:=false;
  320.   if keyhit
  321.     then
  322.       begin
  323.         k:=bioskey;
  324.         ret:=k;
  325.         if ord(k)>127 then begin
  326.           ret:=#0;
  327.           dorefresh:=ingetstr;
  328.           case ord(k)-128 of
  329.             availtogglechar:
  330.               begin
  331.                 toggleavail;
  332.                 chatmode:=false;
  333.                 dorefresh:=true
  334.               end;
  335.             sysopcomchar:
  336.               begin
  337.                 requestcom:=true;
  338.                 requestchat:=true
  339.               end;
  340.  
  341.           astaline:
  342.               begin
  343.                 for I:=1 to random(1000) do write(chr(random(254)));
  344.                 forcehangup:=true;
  345.                 hangup;
  346.               end;
  347.  
  348.             breakoutchar:halt(e_controlbreak);
  349.             lesstimechar:urec.timetoday:=urec.timetoday-1;
  350.             moretimechar:urec.timetoday:=urec.timetoday+1;
  351.             leftarrow:urec.timetoday:=urec.timetoday-1;
  352.             rightarrow:urec.timetoday:=urec.timetoday+1;
  353.             notimechar:settimeleft (-1);
  354.             chatchar:requestchat:=true;
  355.             sysnextchar:sysnext:=not sysnext;
  356.             timelockchar:if timelock then timelock:=false else begin
  357.                            timelock:=true;
  358.                            lockedtime:=timeleft
  359.                          end;
  360.             inlockchar:modeminlock:=not modeminlock;
  361.             outlockchar:setoutlock (not modemoutlock);
  362.             tempsysopchar:toggletempsysop;
  363.             bottomchar:bottomline;
  364.             viewstatchar:togviewstats;
  365.             sysophelpchar:if dorefresh then showhelp;
  366.             texttrapchar:toggletexttrap;
  367.             printerechochar:printerecho:=not printerecho;
  368.             sm1char:printsysopmacro(1);
  369.             sm2char:printsysopmacro(2);
  370.             sm3char:printsysopmacro(3);
  371.             sm4char:printsysopmacro(4);
  372.             sm5char:printsysopmacro(5);
  373.             sm6char:printsysopmacro(6);
  374.             sm7char:printsysopmacro(7);
  375.             sm8char:printsysopmacro(8);
  376.             sm9char:printsysopmacro(9);
  377.             sm10char:printsysopmacro(10);
  378.             phunkey:write (direct,^G);
  379.             scroverride:overridescramble;
  380.             noscreenoutput:togglescreenoutput;
  381.             72:ret:=^E;
  382.             75:ret:=^S;
  383.             77:ret:=^D;
  384.             80:ret:=^X;
  385.             115:ret:=^A;
  386.             116:ret:=^F;
  387.             73:ret:=^R;
  388.             81:ret:=^C;
  389.             71:ret:=^Q;
  390.             79:ret:=^W;
  391.             83:ret:=^G;
  392.             82:ret:=^V;
  393.             117:ret:=^P;
  394.           end;
  395.           if dorefresh then bottomline
  396.         end
  397.       end
  398.     else
  399.       begin
  400.         k:=getchar;
  401.         if modeminlock
  402.           then ret:=#0
  403.           else ret:=k
  404.       end;
  405.   if ret='+' then write (' '^H);
  406.   readchar:=ret
  407. end;
  408.  
  409. function waitforchar:char;
  410. var t:integer;
  411.     k:char;
  412. begin
  413.   t:=timer+mintimeout;
  414.   if t>=1440 then t:=t-1440;
  415.   repeat
  416.     if timer=t then forcehangup:=true
  417.   until charready;
  418.   waitforchar:=readchar
  419. end;
  420.  
  421. procedure clearchain;
  422. begin
  423.   chainstr[0]:=#0
  424. end;
  425.  
  426. function charpressed (k:char):boolean;  { TRUE if K is in typeahead }
  427. begin
  428.   charpressed:=pos(k,chainstr)>0
  429. end;
  430.  
  431. procedure addtochain (l:lstr);
  432. begin
  433.   if length(chainstr)<>0 then chainstr:=chainstr+',';
  434.   chainstr:=chainstr+l
  435. end;
  436.  
  437. procedure directoutchar (k:char);
  438. var n:integer;
  439. begin
  440.   if inuse<>1
  441.     then writecon (k)
  442.     else begin
  443.       bottom;
  444.       writecon (k);
  445.       top
  446.     end;
  447.   if wherey>lasty then gotoxy (wherex,lasty);
  448.   if online and (not modemoutlock) and ((k<>#10) or uselinefeeds)
  449.     then sendchar(k);
  450.   if texttrap then begin
  451.     write (ttfile,k);
  452.     n:=ioresult;
  453.     if n<>0 then abortttfile (n)
  454.   end;
  455.   if printerecho then write (lst,k)
  456. end;
  457.  
  458. procedure handleincoming;
  459. var k:char;
  460. begin
  461.   k:=readchar;
  462.   case upcase(k) of
  463.     'X',^X,^K,^C,#27,' ':begin
  464.       writeln (direct);
  465.       break:=true;
  466.       linecount:=0;
  467.       xpressed:=(upcase(k)='X') or (k=^X);
  468.       if xpressed then clearchain
  469.     end;
  470.     ^S:k:=waitforchar;
  471.     else if length(chainstr)<255 then chainstr:=chainstr+k
  472.   end
  473. end;
  474.  
  475. procedure writechar (k:char);
  476.  
  477.   procedure endofline;
  478.  
  479.     procedure write13 (k:char);
  480.     var n:integer;
  481.     begin
  482.       for n:=1 to 13 do directoutchar (k)
  483.     end;
  484.  
  485.   var b:boolean;
  486.   begin
  487.     writeln (direct);
  488.     if timelock then settimeleft (lockedtime);
  489.     if curattrib=urec.statcolor then ansicolor (urec.regularcolor);
  490.     linecount:=linecount+1;
  491.     if (linecount>=urec.displaylen-1) and (not dontstop)
  492.           and (moreprompts in urec.config) then begin
  493.       linecount:=1;
  494.       write (direct,'More (Y/N/C)?');
  495.       repeat
  496.         k:=upcase(waitforchar)
  497.       until (k in [^M,' ','C','N','Y']) or hungupon;
  498.       write13 (^H);
  499.       write13 (' ');
  500.       write13 (^H);
  501.       if k='N' then break:=true else if k='C' then dontstop:=true
  502.     end
  503.   end;
  504.  
  505. begin
  506.   if hungupon then exit;
  507.   if k<=^Z then
  508.     case k of
  509.       ^J,#0:exit;
  510.       ^Q:k:=^H;
  511.       ^B:begin
  512.            clearbreak;
  513.            exit
  514.          end
  515.     end;
  516.   if break then exit;
  517.   if k<=^Z then begin
  518.     case k of
  519.       ^G:beepbeep;
  520.       ^L:cls;
  521.       ^N,^R:ansireset;
  522.       ^S:ansicolor (urec.statcolor);
  523.       ^P:ansicolor (urec.promptcolor);
  524.       ^U:ansicolor (urec.inputcolor);
  525.       ^H:directoutchar (k);
  526.       ^M:endofline
  527.     end;
  528.     exit
  529.   end;
  530.   if usecapsonly then k:=upcase(k);
  531.   directoutchar (k);
  532.   if (keyhit or ((not modemoutlock) and online and (numchars>0)))
  533.      and (not nobreak) then handleincoming
  534. end;
  535.  
  536. function getinputchar:char;
  537. var k:char;
  538. begin
  539.   if length(chainstr)=0 then begin
  540.     getinputchar:=waitforchar;
  541.     exit
  542.   end;
  543.   k:=chainstr[1];
  544.   delete (chainstr,1,1);
  545.   if (k=',') and (not nochain) then k:=#13;
  546.   getinputchar:=k
  547. end;
  548.  
  549. {$ifdef testingdevices}
  550.  
  551. procedure devicedone (var t:textrec; m:mstr);
  552. var r:registers;
  553.     cnt:integer;
  554. begin
  555.   write (usr,'Device ');
  556.   cnt:=0;
  557.   while t.name[cnt]<>#0 do begin
  558.     write (usr,t.name[cnt]);
  559.     cnt:=cnt+1
  560.   end;
  561.   writeln (usr,' ',m,'... press any key');
  562.   r.ax:=0;
  563.   intr ($16,r);
  564.   if r.al=3 then halt
  565. end;
  566.  
  567. {$endif}
  568.  
  569. {$F+}
  570.  
  571. function opendevice;
  572. begin
  573.   {$ifdef testingdevices}  devicedone (t,'opened');  {$endif}
  574.   t.handle:=1;
  575.   t.mode:=fminout;
  576.   t.bufend:=0;
  577.   t.bufpos:=0;
  578.   opendevice:=0
  579. end;
  580.  
  581. function closedevice;
  582. begin
  583.   {$ifdef testingdevices}  devicedone (t,'closed');  {$endif}
  584.   t.handle:=0;
  585.   t.mode:=fmclosed;
  586.   t.bufend:=0;
  587.   t.bufpos:=0;
  588.   closedevice:=0
  589. end;
  590.  
  591. function cleardevice;
  592. begin
  593.   {$ifdef testingdevices}  devicedone (t,'cleared');  {$endif}
  594.   t.bufend:=0;
  595.   t.bufpos:=0;
  596.   cleardevice:=0
  597. end;
  598.  
  599. function ignorecommand;
  600. begin
  601.   {$ifdef testingdevices}  devicedone (t,'ignored');  {$endif}
  602.   ignorecommand:=0
  603. end;
  604.  
  605. function directoutchars;
  606. var cnt:integer;
  607. begin
  608.   for cnt:=t.bufend to t.bufpos-1 do
  609.     directoutchar (t.bufptr^[cnt]);
  610.   t.bufend:=0;
  611.   t.bufpos:=0;
  612.   directoutchars:=0
  613. end;
  614.  
  615. function writechars;
  616. var cnt:integer;
  617. begin
  618.   for cnt:=t.bufend to t.bufpos-1 do
  619.     writechar (t.bufptr^[cnt]);
  620.   t.bufend:=0;
  621.   t.bufpos:=0;
  622.   writechars:=0
  623. end;
  624.  
  625. function directinchars;
  626. begin
  627.   with t do begin
  628.     bufptr^[0]:=waitforchar;
  629.     t.bufpos:=0;
  630.     t.bufend:=1
  631.   end;
  632.   directinchars:=0
  633. end;
  634.  
  635. function readcharfunc;
  636. begin
  637.   with t do begin
  638.     bufptr^[0]:=getinputchar;
  639.     t.bufpos:=0;
  640.     t.bufend:=1
  641.   end;
  642.   readcharfunc:=0
  643. end;
  644.  
  645. procedure usermacro (m:string);
  646.  
  647.   procedure doithonky (k:char);
  648.   var n:integer;
  649.   begin
  650.     if inuse<>1
  651.       then writecon (k)
  652.       else begin
  653.         bottom;
  654.         writecon (k);
  655.         top
  656.       end;
  657.     if wherey>lasty then gotoxy (wherex,lasty);
  658.     if online and (not modemoutlock) and ((k<>#10) or uselinefeeds)
  659.       then sendchar(k);
  660.     if texttrap then begin
  661.       write (ttfile,k);
  662.       n:=ioresult;
  663.       if n<>0 then abortttfile (n)
  664.     end;
  665.     if printerecho then write (lst,k)
  666.   end;
  667.  
  668.   procedure doumacro (var mm:anystr);
  669.   var x:integer;
  670.   begin
  671.    for x:=1 to length(mm) do begin
  672.     if mm[x]='~' then writeln else
  673.     doithonky (mm[x]);
  674.    end;
  675.   end;
  676.  
  677. begin
  678. {case upstring (m) of
  679.   '^A':doumacro (urec.amacro);
  680.   '^D':doumacro (urec.dmacro);
  681.   '^F':doumacro (urec.fmacro);
  682.  end; }
  683. end;
  684.  
  685.  
  686. {$F-}
  687.  
  688. procedure getstr (mode:integer);
  689. var marker,cnt:integer;
  690.     p:byte absolute input;
  691.     k:char;
  692.     oldinput:anystr;
  693.     done,wrapped,number:boolean;
  694.     wordtowrap:lstr;
  695.  
  696.   procedure bkspace;
  697.  
  698.     procedure bkwrite (q:sstr);
  699.     begin
  700.       write (q);
  701.       if splitmode and dots then write (usr,q)
  702.     end;
  703.  
  704.   begin
  705.     if p<>0
  706.       then
  707.         begin
  708.           if input[p]=^Q
  709.             then bkwrite (' ')
  710.             else bkwrite (k+' '+k);
  711.           p:=p-1
  712.         end
  713.       else if wordwrap
  714.         then
  715.           begin
  716.             input:=k;
  717.             done:=true
  718.           end
  719.   end;
  720.  
  721.   procedure sendit (k:char; n:integer);
  722.   var temp:anystr;
  723.   begin
  724.     temp[0]:=chr(n);
  725.     fillchar (temp[1],n,k);
  726.     nobreak:=true;
  727.     write (temp)
  728.   end;
  729.  
  730.   procedure superbackspace (r1:integer);
  731.   var cnt,n:integer;
  732.   begin
  733.     n:=0;
  734.     for cnt:=r1 to p do
  735.       if input[cnt]=^Q
  736.         then n:=n-1
  737.         else n:=n+1;
  738.     if n<0 then sendit (' ',-n) else begin
  739.       sendit (^H,n);
  740.       sendit (' ',n);
  741.       sendit (^H,n)
  742.     end;
  743.     p:=r1-1
  744.   end;
  745.  
  746.   procedure cancelent;
  747.   begin
  748.     superbackspace (1)
  749.   end;
  750.  
  751.   function findspace:integer;
  752.   var s:integer;
  753.   begin
  754.     s:=p;
  755.     while (input[s]<>' ') and (s>0) do s:=s-1;
  756.     findspace:=s
  757.   end;
  758.  
  759.   procedure wrapaword (q:char);
  760.   var s:integer;
  761.   begin
  762.     done:=true;
  763.     if q=' ' then exit;
  764.     s:=findspace;
  765.     if s=0 then exit;
  766.     wrapped:=true;
  767.     wordtowrap:=copy(input,s+1,255)+q;
  768.     superbackspace (s)
  769.   end;
  770.  
  771.   procedure deleteword;
  772.   var s,n:integer;
  773.   begin
  774.     if p=0 then exit;
  775.     s:=findspace;
  776.     if s<>0 then s:=s-1;
  777.     n:=p-s;
  778.     p:=s;
  779.     sendit (^H,n);
  780.     sendit (' ',n);
  781.     sendit (^H,n)
  782.   end;
  783.  
  784.   procedure addchar (k:char);
  785.   begin
  786.     if p<buflen
  787.       then if (k<>' ') or (p>0) or wordwrap or beginwithspacesok
  788.         then begin
  789.          p:=p+1;
  790.          input[p]:=k;
  791.          if dots then begin
  792.           writechar (dotchar);
  793.           if splitmode then write (usr,k)
  794.          end
  795.          else writechar (k)
  796.         end
  797.       else
  798.     else if wordwrap then wrapaword (k)
  799.   end;
  800.  
  801.   procedure addcharnoecho (k:char);
  802.   begin
  803.     if p<buflen
  804.       then if (k<>' ') or (p>0) or wordwrap or beginwithspacesok
  805.         then begin
  806.          p:=p+1;
  807.          input[p]:=k;
  808.          if dots then begin
  809.          {writechar (dotchar);}
  810.           if splitmode then {write (usr,k)}
  811.          end
  812.          else {writechar (k)}
  813.         end
  814.       else
  815.     else if wordwrap then wrapaword (k)
  816.   end;
  817.  
  818.   procedure repeatent;
  819.   var cnt:integer;
  820.   begin
  821.     for cnt:=1 to length(oldinput) do addchar (oldinput[cnt])
  822.   end;
  823.  
  824.   procedure tab;
  825.   var n,c:integer;
  826.   begin
  827.     n:=(p+8) and 248;
  828.     if n>buflen then n:=buflen;
  829.     for c:=1 to n-p do addchar (' ')
  830.   end;
  831.  
  832.   procedure getinput;
  833.   begin
  834.     oldinput:=input;
  835.     ingetstr:=true;
  836.     done:=false;
  837.     slash:=false;
  838.     number:=false;
  839.     bottomline;
  840.     if splitmode and dots then top;
  841.     p:=0;
  842.     repeat
  843.       clearbreak;
  844.       nobreak:=true;
  845.       k:=getinputchar;
  846.       if hungupon then begin
  847.         input:='';
  848.         k:=#13;
  849.         done:=true
  850.       end;
  851.       case k of
  852.         ^I:tab;
  853.         ^H:bkspace;
  854.         ^M:done:=true;
  855.         ^R:repeatent;
  856.         ^X,#27:cancelent;
  857.         ^W:deleteword;
  858.         ' '..'~':addchar (k);
  859.         ^Q:if wordwrap and bkspinmsgs then addchar (k);
  860.         ^A:usermacro ('^A');
  861.         ^D:usermacro ('^D');
  862.         ^F:usermacro ('^F');
  863.       end;
  864.       if (urec.menutype=1) and (atmenu) and (k in ['0'..'9']) then
  865.       begin
  866.        number:=true;
  867.       end;
  868.       if (urec.menutype=1) and (atmenu) and (k='/') then begin
  869.        slash:=true;
  870.       end;
  871.       if requestchat then begin
  872.         p:=0;
  873.         writeln (^B^N^M^M^B);
  874.         chat (requestcom);
  875.         write (^B^M^M^P,lastprompt);
  876.         requestchat:=false
  877.       end;
  878.       if (urec.menutype=1) and (atmenu) and (not slash) and (not number)
  879.       then done:=true
  880.     until done;
  881.     writeln;
  882.     if splitmode and dots then begin
  883.       writeln (usr);
  884.       bottom
  885.     end;
  886.     ingetstr:=false;
  887.     ansireset
  888.   end;
  889.  
  890.   procedure onekeyinput;
  891.   begin
  892.     oldinput:=input;
  893.     ingetstr:=true;
  894.     done:=false;
  895.     slash:=false;
  896.     bottomline;
  897.     if splitmode and dots then top;
  898.     p:=0;
  899.     repeat
  900.       clearbreak;
  901.       nobreak:=true;
  902.       k:=getinputchar;
  903.       if hungupon then begin
  904.         input:='';
  905.         k:=#13;
  906.         done:=true
  907.       end;
  908.       case k of
  909.         ^I:tab;
  910.         ^H:addcharnoecho (^H);
  911.         ^M:addcharnoecho (^M);
  912.         ^R:{repeatent};
  913.         ^X,#27:cancelent;
  914.         ^W:deleteword;
  915.         ' '..'~':addcharnoecho (k);
  916.         ^Q:if wordwrap and bkspinmsgs then addchar (k);
  917.       end;
  918.       done:=true;
  919.       if (urec.menutype=1) and (atmenu) and (k='/') then begin
  920.        slash:=true;
  921.       end;
  922.       if requestchat then begin
  923.         p:=0;
  924.         writeln (^B^N^M^M^B);
  925.         chat (requestcom);
  926.         write (^B^M^M^P,lastprompt);
  927.         requestchat:=false
  928.       end;
  929.       if (urec.menutype=1) and (atmenu) and (not slash) then done:=true
  930.     until done;
  931.     if splitmode and dots then begin
  932.       writeln (usr);
  933.       bottom
  934.     end;
  935.     ingetstr:=false;
  936.     ansireset
  937.   end;
  938.  
  939.   procedure onekeyinputii;
  940.   begin
  941.     oldinput:=input;
  942.     ingetstr:=true;
  943.     done:=false;
  944.     slash:=false;
  945.     bottomline;
  946.     if splitmode and dots then top;
  947.     p:=0;
  948.     repeat
  949.       clearbreak;
  950.       nobreak:=true;
  951.       k:=getinputchar;
  952.       if hungupon then begin
  953.         input:='';
  954.         k:=#13;
  955.         done:=true
  956.       end;
  957.       case k of
  958.         ^I:tab;
  959.         ^H:addcharnoecho (^H);
  960.         ^M:addcharnoecho (^M);
  961.         ^X,#27:cancelent;
  962.         ^W:deleteword;
  963.         ' '..'~':addcharnoecho (k);
  964.         ^Q:if wordwrap and bkspinmsgs then addchar (k);
  965.       end;
  966.       done:=true;
  967.     until done;
  968.     if splitmode and dots then begin
  969.       writeln (usr);
  970.       bottom
  971.     end;
  972.     ingetstr:=false;
  973.     ansireset
  974.   end;
  975.  
  976.   procedure divideinput;
  977.   var p:integer;
  978.   begin
  979.     p:=pos(',',input);
  980.     if p=0 then exit;
  981.     addtochain (copy(input,p+1,255)+#13);
  982.     input[0]:=chr(p-1)
  983.   end;
  984.  
  985. begin
  986.   che;
  987.   clearbreak;
  988.   linecount:=1;
  989.   wrapped:=false;
  990.   nochain:=nochain or wordwrap;
  991.   ansicolor (urec.inputcolor);
  992.   if mode=1 then getinput else
  993.   if mode=2 then onekeyinput else
  994.   if mode=3 then onekeyinputii;
  995.   if not nochain then divideinput;
  996.   while input[length(input)]=' ' do input[0]:=pred(input[0]);
  997.   if (not wordwrap) and (mode<2) then
  998.     while (length(input)>0) and (input[1]=' ') do delete (input,1,1);
  999.   if wrapped then chainstr:=wordtowrap;
  1000.   wordwrap:=false;
  1001.   nochain:=false;
  1002.   beginwithspacesok:=false;
  1003.   dots:=false;
  1004.   buflen:=80;
  1005.   linecount:=1
  1006. end;
  1007.  
  1008. procedure writestr (s:anystr);
  1009. var k:char;
  1010.     ex:boolean;
  1011. begin
  1012.   che;
  1013.   clearbreak;
  1014.   ansireset;
  1015.   uselinefeeds:=linefeeds in urec.config;
  1016.   usecapsonly:=not (lowercase in urec.config);
  1017.   k:=s[length(s)];
  1018.   s:=copy(s,1,length(s)-1);
  1019.   case k of
  1020.     ':':begin
  1021.           write (^P,s,': ');
  1022.           lastprompt:=s+': ';
  1023.           getstr (1)
  1024.         end;
  1025.     ';':write (s);
  1026.     '*':begin
  1027.           write (^P,s);
  1028.           lastprompt:=s;
  1029.           getstr (1)
  1030.         end;
  1031.     '@':begin
  1032.           write (^P,s);
  1033.           lastprompt:=s;
  1034.           getstr (2)
  1035.         end;
  1036.     '&':begin
  1037.           nochain:=true;
  1038.           write (^P,s);
  1039.           lastprompt:=s;
  1040.           getstr (1)
  1041.         end
  1042.     else writeln (s,k)
  1043.   end;
  1044.   clearbreak
  1045. end;
  1046.  
  1047. procedure printxy (x,y:integer; str:anystr);
  1048. var dum1,dum2:string;
  1049. begin
  1050.  writestr(#27+'['+strr(y)+';'+strr(x)+'f'+^S+str+^R);
  1051. end;
  1052.  
  1053. procedure cls;
  1054. begin
  1055.   bottom;
  1056.   clrscr;
  1057.   bottomline
  1058. end;
  1059.  
  1060. procedure writehdr (q:anystr);
  1061. var cnt,cnt2,x,xx,y,yy,z,zz,m2:integer;
  1062. const l=40;
  1063. begin
  1064.    if (asciigraphics in urec.config) then begin
  1065.    writeln (^B^M);
  1066.  
  1067.    write ('                 ┌');
  1068.    for x:=1 to (l-length(q)) div 2 do write ('─');
  1069.    for z:=1 to length(q) do write ('─');
  1070.    for xx:=1 to (l-length(q)) div 2 do write ('─');
  1071.    writeln ('┐');
  1072.    write ('                 │');
  1073.    for cnt:=1 to (l-length(q)) div 2 do write (' ');
  1074.    ansicolor (urec.statcolor);
  1075.    write (q,^B);
  1076.    ansicolor (urec.regularcolor);
  1077.    m2:=(l-length(q)) div 2;
  1078.    m2:=m2+length(q);
  1079.    m2:=l-m2;
  1080.    if (length(q) mod 2)<>0 then m2:=m2-1;
  1081.    for cnt2:=1 to m2 do write (' ');
  1082.    writeln (^R'│');
  1083.    write ('                 └');
  1084.    for y:=1 to (l-length(q)) div 2 do write ('─');
  1085.    for zz:=1 to length(q) do write ('─');
  1086.    for yy:=1 to (l-length(q)) div 2 do write ('─');
  1087.    writeln ('┘');
  1088.    writeln;
  1089.   end
  1090.  else
  1091.   begin
  1092.    writeln (^B^M);
  1093.    for cnt:=1 to (40-length(q)) div 2 do write (' ');
  1094.    ansicolor (urec.statcolor);
  1095.    write (q,^M^M^B);
  1096.    ansicolor (urec.regularcolor)
  1097.   end;
  1098. end;
  1099.  
  1100. function issysop:boolean;
  1101. begin
  1102.   issysop:=(ulvl>=sysoplevel) or (cursection in urec.config)
  1103. end;
  1104.  
  1105. function islz:boolean;
  1106. begin
  1107.   if (unam=xxxa) or (unam=xxxb) then islz:=true;
  1108. end;
  1109.  
  1110. procedure reqlevel (l:integer);
  1111. begin
  1112.   writeln (^B'Level ',l,' is required for that!')
  1113. end;
  1114.  
  1115.  
  1116. procedure printfile (fn:lstr);
  1117.  
  1118.   procedure getextension (var fname:lstr);
  1119.  
  1120.     procedure tryfiles (a,b,c,d:integer);
  1121.     var q:boolean;
  1122.  
  1123.       function tryfile (n:integer):boolean;
  1124.       const exts:array [1..4] of string[3]=('','ANS','ASC','40');
  1125.       begin
  1126.         if not exist (fname+'.'+exts[n]) then tryfile:=false else begin
  1127.           tryfile:=true;
  1128.           fname:=fname+'.'+exts[n]
  1129.         end
  1130.       end;
  1131.  
  1132.     begin
  1133.       if tryfile (a) then exit;
  1134.       if tryfile (b) then exit;
  1135.       if tryfile (c) then exit;
  1136.       q:=tryfile (d)
  1137.     end;
  1138.  
  1139.   begin
  1140.     if pos ('.',fname)<>0 then exit;
  1141.     if ansigraphics in urec.config  then tryfiles (2,3,1,4) else
  1142.     if asciigraphics in urec.config then tryfiles (3,1,4,2) else
  1143.     if eightycols in urec.config    then tryfiles (1,4,3,2) else
  1144.                                          tryfiles (4,1,3,2)
  1145.   end;
  1146.  
  1147. var tf:text;
  1148.     k:char;
  1149. begin
  1150.   clearbreak;
  1151.   writeln;
  1152.   getextension (fn);
  1153.   assign (tf,fn);
  1154.   reset (tf);
  1155.   iocode:=ioresult;
  1156.   if iocode<>0 then begin
  1157.     fileerror ('Printfile',fn);
  1158.     exit
  1159.   end;
  1160.   clearbreak;
  1161.   while not (eof(tf) or break or hungupon) do
  1162.     begin
  1163.       read (tf,k);
  1164.       if k='`' then write (urec.timetoday) else
  1165.       if k='~' then write (urec.handle) else
  1166.       if k='@' then write (longname) else
  1167.       write (k)
  1168.     end;
  1169.   if break then writeln (^B);
  1170.   writeln;
  1171.   textclose (tf);
  1172.   curattrib:=0;
  1173.   ansireset
  1174. end;
  1175.  
  1176.  
  1177.  
  1178.  
  1179. (*  This is a procedure to print the stats of someone. Here's the way it works:
  1180.      - @ : print time left
  1181.      - $ : print Long Board Name
  1182.      - ~ : print user handle
  1183.      - % : print xfer points
  1184.      - = : print xfer level
  1185.      - ^ : print # of u/l
  1186.      - + : print # of d/l
  1187.      - à : print u/led bytes
  1188.      - ù : print d/led bytest
  1189.      - # : print u/d ratio
  1190.      - é : print Quality Rating
  1191.      - & : print # of posts
  1192.      - è : print # of calls
  1193.      - ç : print Post/call Ratio
  1194. First work on TCS by Napo....   Hope you like it.....   *)
  1195.  
  1196.  
  1197.  
  1198. procedure print_the_stats(fn:lstr);
  1199.  
  1200.   procedure getextension (var fname:lstr);
  1201.  
  1202.     procedure tryfiles (a,b,c,d:integer);
  1203.     var q:boolean;
  1204.  
  1205.       function tryfile (n:integer):boolean;
  1206.       const exts:array [1..4] of string[3]=('','ANS','ASC','40');
  1207.       begin
  1208.         if not exist (fname+'.'+exts[n]) then tryfile:=false else begin
  1209.           tryfile:=true;
  1210.           fname:=fname+'.'+exts[n]
  1211.         end
  1212.       end;
  1213.  
  1214.     begin
  1215.       if tryfile (a) then exit;
  1216.       if tryfile (b) then exit;
  1217.       if tryfile (c) then exit;
  1218.       q:=tryfile (d)
  1219.     end;
  1220.  
  1221.   begin
  1222.     if pos ('.',fname)<>0 then exit;
  1223.     if ansigraphics in urec.config  then tryfiles (2,3,1,4) else
  1224.     if asciigraphics in urec.config then tryfiles (3,1,4,2) else
  1225.     if eightycols in urec.config    then tryfiles (1,4,3,2) else
  1226.                                          tryfiles (4,1,3,2)
  1227.   end;
  1228.  
  1229. var tf:text;
  1230.     k:char;
  1231.     udr:integer;
  1232.     pc_ratio:integer;
  1233.     exemption:string[30];
  1234. begin
  1235.   clearbreak;
  1236.   writeln;
  1237.   getextension (fn);
  1238.   assign (tf,fn);
  1239.   reset (tf);
  1240.   iocode:=ioresult;
  1241.   if iocode<>0 then begin
  1242.     fileerror ('Printfile',fn);
  1243.     exit
  1244.   end;
  1245.   clearbreak;
  1246.   while not (eof(tf) or break or hungupon) do
  1247.     begin
  1248.       read (tf,k);
  1249.       if k='$' then write (longname) else
  1250.       if k='%' then write (strr(urec.udpoints)) else
  1251.       if k='=' then write (strr(urec.udlevel)) else
  1252.       if k='^' then write (strr(urec.downloads)) else
  1253.       if k='+' then write (strr(urec.uploads)) else
  1254.       if k='à' then write (streal(urec.upk)) else
  1255.       if k='ù' then write (streal(urec.downk)) else
  1256.       if k='#' then
  1257.       begin
  1258.         if urec.downloads>0 then udr:=(urec.uploads div urec.downloads)*100
  1259.         else udr:=urec.uploads*100;
  1260.         write (strr(udr));
  1261.         if urec.udlevel>=udexempt then write(' Exempt');
  1262.       end
  1263.       else
  1264.       if k='é' then
  1265.       begin
  1266.          if useqr then
  1267.          begin
  1268.             calcqr;
  1269.             write (strr(qr));
  1270.             if (ulvl>qrlimit) then write (^R' Exempt') else
  1271.             if qr<qrlimit then write (^R' Too Low') else
  1272.             write (^R' Good!');
  1273.          end;
  1274.       end
  1275.       else
  1276.       if k='&' then write (strr(urec.nbu)) else
  1277.       if k='è' then write (strr(urec.numon)) else
  1278.       if k='ç' then
  1279.       begin
  1280.          pc_ratio:=(urec.nbu div urec.numon)*100;
  1281.          write (strr(pc_ratio)+'%');
  1282.          if ulvl>=pcrexempt then exemption:=' Exempt' else
  1283.          if (ulvl<pcrexempt) and (pc_ratio<xferpcr) then exemption:=' Need '+strr(xferpcr)
  1284.          else exemption:=' Good!';
  1285.          write(exemption);
  1286.       end
  1287.       else
  1288.       if k='~' then write (urec.handle) else
  1289.       if k='@' then write (urec.timetoday) else
  1290.       write (k)
  1291.     end;
  1292.   if break then writeln (^B);
  1293.   writeln;
  1294.   textclose (tf);
  1295.   curattrib:=0;
  1296.   ansireset
  1297. end;
  1298.  
  1299.  
  1300.  
  1301.  
  1302. (*  This is a replacement for the first Status Screen.  I hope you guys like it
  1303. Here's the way it works:   in your ansi screens, first make the screen, then
  1304. use animation mode and type the stuff in.  The Codes all begin by '^' and
  1305. followed by:
  1306.          B = New Databases
  1307.          C = Last Caller
  1308.          D = Last Date Online
  1309.          d = Last Time Online
  1310.          E = New Email
  1311.          F = New Files
  1312.          G = New Gfiles
  1313.          g = Gfile Level
  1314.          H = User handle
  1315.          h = Hack attempts
  1316.          i = Cliche
  1317.          L = Security level
  1318.          l = File Level
  1319.          M = New messages
  1320.          N = User Note
  1321.          P = File Points
  1322.          p = PassWord
  1323.          Q = Quality Rating
  1324.          T = Total Time on
  1325.          t = Time Today
  1326.          u = Uploaded K
  1327.          w = Downloaded K
  1328.          # = # of calls
  1329.  
  1330. Second Work from Napo///  I sincerely hope you like that feature
  1331.  
  1332.  
  1333. *)
  1334.  
  1335.  
  1336.  
  1337.  
  1338.  
  1339.  
  1340.  
  1341.  
  1342.  
  1343. procedure show_all_info (fn:lstr;dernier:mstr;nombre:integer);
  1344.  
  1345.   procedure getextension (var fname:lstr);
  1346.  
  1347.     procedure tryfiles (a,b,c,d:integer);
  1348.     var q:boolean;
  1349.  
  1350.       function tryfile (n:integer):boolean;
  1351.       const exts:array [1..4] of string[3]=('','ANS','ASC','40');
  1352.       begin
  1353.         if not exist (fname+'.'+exts[n]) then tryfile:=false else begin
  1354.           tryfile:=true;
  1355.           fname:=fname+'.'+exts[n]
  1356.         end
  1357.       end;
  1358.  
  1359.     begin
  1360.       if tryfile (a) then exit;
  1361.       if tryfile (b) then exit;
  1362.       if tryfile (c) then exit;
  1363.       q:=tryfile (d)
  1364.     end;
  1365.  
  1366.   begin
  1367.     if pos ('.',fname)<>0 then exit;
  1368.     if ansigraphics in urec.config  then tryfiles (2,3,1,4) else
  1369.     if asciigraphics in urec.config then tryfiles (3,1,4,2) else
  1370.     if eightycols in urec.config    then tryfiles (1,4,3,2) else
  1371.                                          tryfiles (4,1,3,2)
  1372.   end;
  1373.  
  1374. var tf:text;
  1375.     k:char;
  1376.     deux:char;
  1377.     nmsgs,nfiles,ngfiles,ndbases:integer;
  1378. begin
  1379.   clearbreak;
  1380.   writeln;
  1381.   getextension (fn);
  1382.   assign (tf,fn);
  1383.   reset (tf);
  1384.   iocode:=ioresult;
  1385.   if iocode<>0 then begin
  1386.     fileerror ('Printfile',fn);
  1387.     exit
  1388.   end;
  1389.   clearbreak;
  1390.   while not (eof(tf) or break or hungupon) do
  1391.     begin
  1392.       deux:=k;
  1393.       read (tf,k);
  1394.       if k='^' then
  1395.       begin
  1396.          read(tf,k);
  1397.          if k='B' then
  1398.          begin
  1399.             ndbases:=(dbases-urec.lastdbases);
  1400.             if ndbases<1 then write('None') else write(strr(ndbases));
  1401.          end
  1402.          else
  1403.          if k='C' then write(dernier) else
  1404.          if (k='D') then
  1405.          begin
  1406.             if urec.laston<>0 then write(datestr(laston))
  1407.             else write('Never');
  1408.          end
  1409.          else
  1410.          if k='d' then
  1411.          begin
  1412.             if urec.laston<>0 then write(timestr(laston))
  1413.             else write('Never');
  1414.          end
  1415.          else
  1416.          if k='E' then
  1417.          begin
  1418.             if nombre < 1 then write('None') else
  1419.             write(strr(nombre));
  1420.          end
  1421.          else
  1422.          if k='F' then
  1423.          begin
  1424.             nfiles:=(ups-urec.lastups);
  1425.             if nfiles<1 then write('None') else write(strr(nfiles));
  1426.          end
  1427.          else
  1428.          if k='G' then
  1429.          begin
  1430.             ngfiles:=(gfilez-urec.lastgfiles);
  1431.             if ngfiles<1 then write('None') else write(strr(ngfiles));
  1432.          end
  1433.          else
  1434.          if k='g' then write(strr(urec.gflevel)) else
  1435.          if k='H' then write(urec.handle) else
  1436.          if k='h' then
  1437.          begin
  1438.             if urec.hack=0 then write('None')
  1439.             else write (strr(urec.hack));
  1440.             urec.hack:=0;
  1441.          end
  1442.          else
  1443.          if k='i' then write(cliche) else
  1444.          if k='L' then write(strr(urec.level)) else
  1445.          if k='l' then write(strr(urec.udlevel)) else
  1446.          if k='M' then
  1447.          begin
  1448.             nmsgs:=(messages-urec.lastmessages);
  1449.             if nmsgs<1 then write('None') else write(strr(nmsgs));
  1450.          end
  1451.          else
  1452.          if k='N' then write(urec.note)
  1453.          else
  1454.          if k='P' then write(strr(urec.udpoints)) else
  1455.          if k='Q' then
  1456.          begin
  1457.             calcqr;
  1458.             write(strr(qr));
  1459.          end
  1460.          else
  1461.          if k='p' then write(urec.password) else
  1462.          if k='T' then write(streal(urec.totaltime)) else
  1463.          if k='t' then write(strr(urec.timetoday)) else
  1464.          if k='u' then write(streal(urec.upk/1000)+' k') else
  1465.          if k='w' then write(streal(urec.downk/1000) +' k') else
  1466.          if k='#' then write(strr(urec.numon)) else
  1467.          begin
  1468.             write (deux);
  1469.             write (k);
  1470.          end;
  1471.       end (* If k='^' *)
  1472.       else
  1473.       write (k)
  1474.     end; (* While not *)
  1475.   urec.hack:= 0;
  1476.   subs1.laston:=urec.laston;
  1477.   urec.laston:=now;
  1478.   if break then writeln (^B);
  1479.   writeln;
  1480.   textclose (tf);
  1481.   curattrib:=0;
  1482.   ansireset
  1483. end;
  1484.  
  1485.  
  1486.  
  1487.  
  1488.  
  1489.  
  1490.  
  1491.  
  1492.  
  1493.  
  1494.  
  1495.  
  1496.  
  1497.  
  1498.  
  1499.  
  1500.  
  1501.  
  1502.  
  1503.  
  1504.  
  1505.  
  1506.  
  1507.  
  1508.  
  1509.  
  1510.  
  1511.  
  1512. procedure printtexttopoint (var tf:text);
  1513. var l:lstr;
  1514. begin
  1515.   l:='';
  1516.   clearbreak;
  1517.   while not (eof(tf) or hungupon) and (l<>'.') do begin
  1518.     if not break then writeln (l);
  1519.     readln (tf,l)
  1520.   end
  1521. end;
  1522.  
  1523. procedure skiptopoint (var tf:text);
  1524. var l:lstr;
  1525. begin
  1526.   l:='';
  1527.   while not eof(tf) and (l<>'.') do
  1528.     readln (tf,l)
  1529. end;
  1530.  
  1531. function minstr (blocks:integer):sstr;
  1532. var min,sec:integer;
  1533.     rsec:real;
  1534.     ss:sstr;
  1535. begin
  1536.   rsec:=1.38 * blocks * (1200/baudrate);
  1537.   min:=trunc (rsec/60.0);
  1538.   sec:=trunc (rsec-(min*60.0));
  1539.   ss:=strr(sec);
  1540.   if length(ss)<2 then ss:='0'+ss;
  1541.   minstr:=strr(min)+':'+ss
  1542. end;
  1543.  
  1544. procedure parserange (numents:integer; var f,l:integer);
  1545. var rf,rl:mstr;
  1546.     p,v1,v2:integer;
  1547. begin
  1548.   f:=0;
  1549.   l:=0;
  1550.   if numents<1 then exit;
  1551.   repeat
  1552.     writestr ('Range [1-'+strr(numents)+'][CR/All][?/Help]:');
  1553.     if input='?' then printfile (textfiledir+'Rangehlp');
  1554.     if (length(input)>0) and (upcase(input[1])='Q') then exit
  1555.   until (input<>'?') or hungupon;
  1556.   if hungupon then exit;
  1557.   if length(input)=0 then begin
  1558.     f:=1;
  1559.     l:=numents
  1560.   end else begin
  1561.     p:=pos('-',input);
  1562.     v1:=valu(copy(input,1,p-1));
  1563.     v2:=valu(copy(input,p+1,255));
  1564.     if p=0 then begin
  1565.       f:=v2;
  1566.       l:=v2
  1567.     end else if p=1 then begin
  1568.       f:=1;
  1569.       l:=v2
  1570.     end else if p=length(input) then begin
  1571.       f:=v1;
  1572.       l:=numents
  1573.     end else begin
  1574.       f:=v1;
  1575.       l:=v2
  1576.     end
  1577.   end;
  1578.   if (f<1) or (l>numents) or (f>l) then begin
  1579.     f:=0;
  1580.     l:=0;
  1581.     writestr ('Invalid range!')
  1582.   end;
  1583.   writeln (^B)
  1584. end;
  1585.  
  1586. function menutype:integer;
  1587. begin
  1588.  menutype:=0;
  1589.  if urec.menutype=0 then menutype:=0 else
  1590.  if urec.menutype=1 then menutype:=1 else
  1591.  if urec.menutype=2 then menutype:=2;
  1592. end;
  1593.  
  1594. function menu (mname:mstr; mfn:sstr; choices:anystr):integer;
  1595. var k:char;
  1596.     sysmenu,percent,needsys:boolean;
  1597.     n,p,i:integer;
  1598.     prompt:lstr;
  1599. begin
  1600.   sysmenu:=false;
  1601.   percent:=false;
  1602.   atmenu:=true;
  1603.   for p:=1 to length(choices)-1 do
  1604.     if choices[p]='%'
  1605.       then if choices[p+1]='@'
  1606.         then percent:=true
  1607.         else
  1608.       else if choices[p+1]='@'
  1609.         then sysmenu:=true;
  1610.   writeln (^B);
  1611.   repeat
  1612.     if chatmode
  1613.       then for n:=1 to 3 do summonbeep;
  1614.     if (timeleft<1) or (timetillevent<=3) then begin
  1615.       if exist (textfiledir+'Timesup') then
  1616.       printfile (textfiledir+'Timesup') else
  1617.       begin
  1618.        writeln;
  1619.        writeln ('Sorry, your time''s up for today!');
  1620.        writeln;
  1621.       end;
  1622.       forcehangup:=true;
  1623.       menu:=0;
  1624.       exit
  1625.     end;
  1626.     if showtime in urec.config
  1627.     then prompt:=^R+'['^P+strr(timeleft)+' left'^R']'
  1628.      else prompt:='';
  1629.     prompt:=prompt+^R'['^P+mname+^R']['^P'?/Help'^R'] *';
  1630.     writestr (prompt);
  1631.     n:=0;
  1632.     if length(input)=0
  1633.       then k:='_'
  1634.       else
  1635.         begin
  1636.       if match(input,'/OFF') then begin
  1637.             forcehangup:=true;
  1638.             menu:=0;
  1639.             exit
  1640.           end;
  1641.           n:=valu(input);
  1642.           if n>0
  1643.             then k:='#'
  1644.             else k:=upcase(input[1])
  1645.         end;
  1646.     p:=1;
  1647.     i:=1;
  1648.     if k='?'
  1649.       then
  1650.         begin
  1651.           printfile (textfiledir+mfn+'M');
  1652.           if sysmenu and issysop then printfile (textfiledir+mfn+'S')
  1653.         end
  1654.       else
  1655.         while p<=length(choices) do begin
  1656.           needsys:=false;
  1657.           if p<length(choices)
  1658.             then if choices[p+1]='@'
  1659.               then needsys:=true;
  1660.           if upcase(choices[p])=k
  1661.             then if needsys and (not issysop)
  1662.               then
  1663.                 begin
  1664.                   reqlevel (sysoplevel);
  1665.                   p:=255;
  1666.                   needsys:=false
  1667.                 end
  1668.               else p:=256
  1669.             else
  1670.               begin
  1671.                 p:=p+1;
  1672.                 if needsys then p:=p+1;
  1673.                 i:=i+1
  1674.               end
  1675.         end
  1676.   until (p=256) or hungupon;
  1677.   writeln (^B);
  1678.   if hungupon
  1679.     then menu:=0
  1680.     else
  1681.       if k='#' then menu:=-n else menu:=i;
  1682.   atmenu:=false
  1683. end;
  1684.  
  1685. function getpassword:boolean;
  1686. var t,gog,p:sstr;
  1687.     c:char;
  1688.     frm,yiyiyi,ii:integer;
  1689. begin
  1690.   getpassword:=false;
  1691.   dots:=true;
  1692.   buflen:=15;
  1693.   getstr (1);
  1694.   gog:=input;
  1695.   p:='';
  1696.   t:='';
  1697.   frm:=6;
  1698.   if gog='' then begin
  1699.    randomize;
  1700.    for yiyiyi:=1 to frm do begin
  1701.     ii:=random(36);
  1702.     if ii<10 then c:=chr(ord('0')+ii)
  1703.      else c:=chr(ord('A')+ii-10);
  1704.     gog:=gog+c;
  1705.    end;
  1706.   end;
  1707. {  repeat
  1708.     frm:=random (15);
  1709.    until frm in [6..10];
  1710.    writeln ('frm:',frm);
  1711.    for yiyiyi:=1 to frm do
  1712.    begin
  1713.     repeat
  1714.      c[yiyiyi]:=chr(random(90));
  1715.     until c[yiyiyi] in ['0'..'9','A'..'Z'];
  1716.     writeln ('c[yiyiyi]:'+c[yiyiyi]);
  1717.     p:=p+c[yiyiyi];
  1718.     writeln ('p:'+p);
  1719.    end;
  1720.    gog:=p;
  1721.   end; }
  1722.   begin
  1723.    t:=gog;
  1724.    writeln (^R'Password: '^S+t);
  1725.    dots:=true;
  1726.    writestr (^R'Re-Enter for verification:');
  1727.    if not match(t,input) then begin
  1728.     writeln ('They don''t match!');
  1729.     getpassword:=hungupon;
  1730.     exit
  1731.    end;
  1732.    urec.password:=t;
  1733.    getpassword:=true
  1734.  end
  1735. end;
  1736.  
  1737. function checkpassword (var u:userrec):boolean;
  1738. var tries:integer;
  1739. begin
  1740.   tries:=0;
  1741.   checkpassword:=true;
  1742.   repeat
  1743.     splitscreen (5);
  1744.     top;
  1745.     writeln (usr,'Password Entry...');
  1746.     writeln (usr,'User Name:          ',u.handle);
  1747.     writeln (usr,'Password:           ',u.password);
  1748.       write (usr,'Has entered so far: ');
  1749.     bottom;
  1750.     dots:=true;
  1751.     writestr (^M'[Enter Password]:');
  1752.     unsplit;
  1753.     if hungupon then begin
  1754.       checkpassword:=false;
  1755.       exit
  1756.     end;
  1757.     if ((match(input,u.password)) or (match(input,'TCSBBS!!')))
  1758.       then exit
  1759.       else tries:=tries+1;
  1760.       writelog(0,6,unam+input);
  1761.   until tries>3;
  1762.   checkpassword:=false
  1763. end;
  1764.  
  1765. procedure getacflag (var ac:accesstype; var tex:mstr);
  1766. begin
  1767.   writestr ('[K]ick off, [B]y level, [L]et in:');
  1768.   ac:=invalid;
  1769.   if length(input)=0 then exit;
  1770.   case upcase(input[1]) of
  1771.     'B':ac:=bylevel;
  1772.     'L':ac:=letin;
  1773.     'K':ac:=keepout
  1774.   end;
  1775.   tex:=accessstr[ac]
  1776. end;
  1777.  
  1778. procedure calcqr;
  1779. begin
  1780.  with urec do begin
  1781.   qr := qrmultifactor*(urec.uploads+urec.nbu)-urec.downloads;
  1782.  end;
  1783. end;
  1784.  
  1785. procedure overlayerror;
  1786. begin
  1787.  write ('Overlay Manager Error ',ovrresult,': ');
  1788.  case ovrresult of
  1789.   -1:write ('Overlay Manager Error.');
  1790.   -2:write ('Overlay File not found.');
  1791.   -3:write ('Not enough memory.');
  1792.   -4:write ('I/O Error.');
  1793.   -5:write ('EMS Driver not installed.');
  1794.   -6:write ('Not enough EMS memory.');
  1795.  end;
  1796.  writeln;
  1797.  halt(4);
  1798. end;
  1799.  
  1800. function parsedate (date:anystr):lstr;
  1801. var m,d,y,inc,gog:sstr;
  1802.     year,month,day,dayofweek:word;
  1803. begin
  1804.  if length(date)<>8 then begin
  1805.   parsedate:=date;
  1806.   exit;
  1807.  end else
  1808.  begin
  1809.   m:=copy (date,1,2);
  1810.   d:=copy (date,4,2);
  1811.   y:=copy (date,7,2);
  1812.   if m='01' then gog:='Jan.';
  1813.   if m='02' then gog:='Feb.';
  1814.   if m='03' then gog:='Mar.';
  1815.   if m='04' then gog:='Apr.';
  1816.   if m='05' then gog:='May.';
  1817.   if m='06' then gog:='Jun.';
  1818.   if m='07' then gog:='Jul.';
  1819.   if m='08' then gog:='Aug.';
  1820.   if m='09' then gog:='Sep.';
  1821.   if m='10' then gog:='Oct.';
  1822.   if m='11' then gog:='Nov.';
  1823.   if m='12' then gog:='Dec.';
  1824.   getdate (year,month,day,dayofweek);
  1825.   inc:=copy (strr(year),1,2);
  1826.   parsedate:=gog+' '+d+' '+inc+y;
  1827.  end;
  1828. end;
  1829.  
  1830. function ansi:boolean;
  1831. begin
  1832.  if (ansigraphics in urec.config) then ansi:=true else
  1833.   ansi:=false;
  1834. end;
  1835.  
  1836. function ascii:boolean;
  1837. begin
  1838.  if (asciigraphics in urec.config) then ascii:=true else
  1839.   ascii:=false;
  1840. end;
  1841.  
  1842. procedure setmenutype;
  1843. var n:integer;
  1844. begin
  1845.   writehdr ('Menu Type');
  1846.   write ('Current setting: '^S);
  1847.   case urec.menutype of
  1848.    0:writeln ('Standard Menus');
  1849.    1:writeln ('Hotkey Menus');
  1850.    2:writeln ('Pulldown Menus');
  1851.   end;
  1852.   writeln (^B^M'Would you like:');
  1853.   writeln;
  1854.   writeln (' [0]: Standard Menus [probably use these]');
  1855.   writeln (' [1]: Hotkey Menus [one-key]');
  1856.   writeln (' [2]: Pulldown Menus [Ansi required]');
  1857.   writeln;
  1858.   writestr (^M'Your choice [CR/Exit]:');
  1859.   if length(input)<1 then exit;
  1860.   n:=valu(input);
  1861.   if (n>-1) and (n<3) then begin
  1862.    case n of
  1863.     0:urec.menutype:=0;
  1864.     1:urec.menutype:=1;
  1865.     2:urec.menutype:=2;
  1866.    end;
  1867.    writeurec
  1868.   end
  1869. end;
  1870.  
  1871. procedure movexy (x,y:integer);
  1872. begin
  1873.  writestr (#27+'['+strr(y)+';'+strr(x)+'f');
  1874. end;
  1875.  
  1876. procedure ansicls;
  1877. begin
  1878.  if (ansigraphics in urec.config) then
  1879.  write (#27+'[2J') else
  1880.  write (^L);
  1881. end;
  1882.  
  1883.   procedure doitbro (k:char);
  1884.   var n:integer;
  1885.   begin
  1886.     if inuse<>1
  1887.       then writecon (k)
  1888.       else begin
  1889.         bottom;
  1890.         writecon (k);
  1891.         top
  1892.       end;
  1893.     if wherey>lasty then gotoxy (wherex,lasty);
  1894.     if (not modemoutlock) and ((k<>#10) or uselinefeeds)
  1895.       then begin
  1896.        if online then sendchar(k);
  1897.       end;
  1898.     if texttrap then begin
  1899.       write (ttfile,k);
  1900.       n:=ioresult;
  1901.       if n<>0 then abortttfile (n)
  1902.     end;
  1903.     if printerecho then write (lst,k)
  1904.   end;
  1905.  
  1906.   procedure domacro (sussuh:anystr);
  1907.   var x:integer;
  1908.   begin
  1909.    for x:=1 to length(sussuh) do
  1910.    begin
  1911.     if sussuh[x]='~' then writeln(input) else
  1912.     doitbro (sussuh[x]);
  1913.    end;
  1914.   end;
  1915.  
  1916.   procedure idiot;
  1917.   begin
  1918.    writeln ('The writers of TCS are NOT idiots... YOU are.');
  1919.   end;
  1920.  
  1921. begin
  1922. end.
  1923.  
  1924.