home *** CD-ROM | disk | FTP | other *** search
/ Jason Aller Floppy Collection / 189.img / TCS120S.ZIP / GFILES.PAS < prev    next >
Pascal/Delphi Source File  |  1989-04-06  |  38KB  |  1,398 lines

  1. {$R-,S-,I-,D-,F+,V-,B-,N-,O+ }
  2. {$M 65500,0,0 }
  3.  
  4. unit gfiles;
  5.  
  6. interface
  7.  
  8. uses crt,dos,turbo3,
  9.      gentypes,configrt,modem,statret,gensubs,subs1,windows,subs2,textret,
  10.      mailret,userret,flags,mainr1,ansiedit,lineedit,chatstuf,
  11.      mainr2,overret1,protocol,mainmenu;
  12.  
  13. procedure gfilesection;
  14.  
  15. implementation
  16.  
  17. procedure gfilesection;
  18. var showit,itsotay,ymodem:boolean;
  19.  
  20. var gfile:file of gfilerec;
  21.     gf:gfilerec;
  22.     gfilea:file of gfilearea;
  23.     gfa:gfilearea;
  24.     curarea:integer;
  25.  
  26. procedure beepbeep (ok:integer);
  27. begin
  28.  delay (500);
  29.  write (^B^M);
  30.  case ok of
  31.   0:write ('Xfer completed!');
  32.   1:write ('Xfer Aborted just before EOF!');
  33.   2:write ('Xfer Aborted!')
  34.  end;
  35.  writeln (^G^M)
  36. end;
  37.  
  38. procedure parse3 (s:lstr; var a,b,c:integer);
  39. var p:integer;
  40.  
  41.   procedure parse1 (var n:integer);
  42.   var ns:lstr;
  43.   begin
  44.     ns[0]:=#0;
  45.     while (p<=length(s)) and (s[p] in ['0'..'9']) do begin
  46.       ns:=ns+s[p];
  47.       p:=p+1
  48.     end;
  49.     if length(ns)=0
  50.       then n:=0
  51.       else n:=valu(ns);
  52.     if p<length(s) then p:=p+1
  53.   end;
  54.  
  55. begin
  56.   p:=1;
  57.   parse1 (a);
  58.   parse1 (b);
  59.   parse1 (c)
  60. end;
  61.  
  62. function later (d1,t1,d2,t2:sstr):boolean;
  63. var m1,da1,y1,m2,da2,y2:integer;
  64.  
  65.   function latertime (t1,t2:sstr):boolean;
  66.   var n1,n2:integer;
  67.   begin
  68.     latertime:=timeval(t1)>timeval(t2)
  69.   end;
  70.  
  71. begin
  72.   parse3 (d1,m1,da1,y1);
  73.   parse3 (d2,m2,da2,y2);
  74.   if y1=y2
  75.     then if m1=m2
  76.       then if da1=da2
  77.         then later:=timeval(t1) > timeval(t2)
  78.         else later:=da1>da2
  79.       else later:=m1>m2
  80.     else later:=y1>y2
  81. end;
  82.  
  83.   function Numgfiles:integer;
  84.   begin
  85.     numgfiles:=filesize(gfile)
  86.   end;
  87.  
  88.   function NumAreas:integer;
  89.   begin
  90.     numareas:=filesize (gfilea)
  91.   end;
  92.  
  93.   procedure Seekgfile (n:integer);
  94.   begin
  95.     seek (gfile,n-1)
  96.   end;
  97.  
  98.   procedure Seekgfilea (n:integer);
  99.   begin
  100.     seek (gfilea,n-1)
  101.   end;
  102.  
  103.   procedure Assigngf (N:Integer);
  104.   begin
  105.     close (gfile);
  106.     assign (gfile,uploaddir+'gfILE'+strr(n));
  107.   end;
  108.  
  109.   function Makearea:boolean;
  110.   var num,n:integer;
  111.       gfatmp:gfilearea;
  112.   begin
  113.     makearea:=false;
  114.     writestr ('Create Area '+strr(numareas+1)+'? *');
  115.     writeln;
  116.     if yes then begin
  117.       writestr ('Area Name: *');
  118.       if length(input)=0 then exit;
  119.       gfatmp.Name:=input;
  120.       writestr ('Access Level: *');
  121.       if length(input)=0 then exit;
  122.       gfatmp.Level:=valu(input);
  123.       writestr ('Sponsor [CR/'+unam+']:');
  124.       if length(input)=0 then input:=unam;
  125.       gfatmp.Sponsor:=input;
  126.       gfatmp.UpAble:=True;
  127.       writestr('Able to Upload to area [CR/Yes]: *');
  128.       if length(input)=0 then input:='Y';
  129.       if upcase(input[1])<>'Y' then gfatmp.UpAble:=False;
  130.       writestr('Upload Directory [CR/'+uploaddir+']: *');
  131.       if length(input)=0 then input:=uploaddir;
  132.       gfatmp.gfileDir:=input;
  133.       Seekgfilea (numareas+1);
  134.       write (gfilea,gfatmp);
  135.       gfa:=gfatmp;
  136.       Curarea:=NumAreas+1;
  137.       Assigngf(CurArea);
  138.       rewrite (gfile);
  139.       writeln ('Area created');
  140.       makearea:=true;
  141.       writelog (3,6,gfatmp.Name);
  142.     end
  143.  
  144.   end;
  145.  
  146.   procedure Opengfile;
  147.   var n:integer;
  148.   begin
  149.     n:=ioresult;
  150.     assign (gfilea,uploaddir+'gfileDir');
  151.     reset (gfilea);
  152.     if ioresult<>0 then begin
  153.       close (gfilea);
  154.       n:=ioresult;
  155.       rewrite (gfilea);
  156.       itsotay:=makearea;
  157.     end else itsotay:=true;
  158.   end;
  159.  
  160.   function getfname (path:lstr; name:mstr):lstr;
  161.   var l:lstr;
  162.   begin
  163.     l:=path;
  164.     if length(l)<>0 then
  165.       if not (upcase(l[length(l)]) in [':','\'])
  166.         then l:=l+'\';
  167.     l:=l+name;
  168.     getfname:=l;
  169.   end;
  170.  
  171.   function getapath:lstr;
  172.   var q,r:integer;
  173.       f:file;
  174.       b:boolean;
  175.       p:lstr;
  176.   begin
  177.     getapath:=gfa.gfiledir;
  178.     repeat
  179.       writestr ('Upload Path [CR/'+gfa.gfileDir+']:');
  180.       if hungupon then exit;
  181.       if length(input)=0 then input:=gfa.gfileDir;
  182.       p:=input;
  183.       if input[length(p)]<>'\' then p:=p+'\';
  184.       b:=true;
  185.       assign (f,p+'CON');
  186.       reset (f);
  187.       q:=ioresult;
  188.       close (f);
  189.       r:=ioresult;
  190.       if q<>0 then begin
  191.         writestr ('  Path does not exist.  Create it [y/n]? *');
  192.         b:=yes;
  193.         if b then begin
  194.           mkdir (copy(p,1,length(p)-1));
  195.           q:=ioresult;
  196.           b:=q=0;
  197.           if b then writestr ('Directory created.')
  198.             else writestr ('Unable to create directory.')
  199.         end
  200.       end
  201.     until b;
  202.     getapath:=p;
  203.   end;
  204.  
  205.   procedure fastlistfile (n:integer);
  206.   var q:sstr;
  207.   begin
  208.     seekgfile (n);
  209.     read (gfile,gf);
  210.     writeln;
  211.     ansicolor (urec.statcolor);
  212.     tab (strr(n)+'.',5);
  213.     ansicolor (urec.regularcolor);
  214.     if break then exit;
  215.       if exist(getfname(gf.path,gf.fname)) then
  216.         tab (streal(gf.filesize),8) else tab ('Offline',8);
  217.     if break then exit;
  218.     ansicolor (urec.statcolor);
  219.     tab (gf.gfiledescr,66);
  220.     ansicolor (urec.regularcolor);
  221.     if break then exit;
  222.   end;
  223.  
  224.   function NoFiles:boolean;
  225.   begin
  226.     if Numgfiles=0 then begin
  227.       nofiles:=true;
  228.       writestr (^M'Sorry, No G-Files!')
  229.     end else nofiles:=false
  230.   end;
  231.  
  232.   procedure FastListgfiles;
  233.   var cnt,max,r1,r2,r3:integer;
  234.   begin
  235.     if nofiles then exit;
  236.     writehdr ('File List'^M);
  237.     max:=Numgfiles;
  238.     thereare (max,'G-File','G-Files');
  239.     parserange (max,r1,r2);
  240.     if r1=0 then exit;
  241.     tab ('No.',5);
  242.     tab ('Bytes',8);
  243.     tab ('Description',66);
  244.     writeln;
  245.     r3:=0;
  246.     for cnt:=r1 to r2 do begin
  247.     r3:=r3+2;
  248.       FASTlistfile (cnt);
  249.       if break then exit
  250.     end;
  251.     writeln;
  252.   end;
  253.  
  254.   function GetgfileNum (t:mstr):integer;
  255.   var n,s:integer;
  256.  
  257.     function SearchforFile (f:sstr):integer;
  258.     var cnt:integer;
  259.     begin
  260.       for cnt:=1 to numgfiles do begin
  261.         seekgfile (cnt);
  262.         read (gfile,gf);
  263.         if match(gf.fname,f) then begin
  264.           searchforfile:=cnt;
  265.           exit
  266.         end
  267.       end;
  268.       searchforfile:=0
  269.     end;
  270.   begin
  271.     getgfilenum:=0;
  272.     if length(input)>1 then input:=copy(input,2,255) else
  273.       repeat
  274.         writestr ('File Number to '+t+' [?/List]:');
  275.         if hungupon or (length(input)=0) then exit;
  276.         if input='?' then begin
  277.           fastlistgfiles;
  278.           input:=''
  279.         end
  280.       until input<>'';
  281.     val (input,n,s);
  282.     if s<>0 then begin
  283.       n:=searchforfile(input);
  284.       if n=0 then begin
  285.         writeln ('No such file.');
  286.         exit
  287.       end
  288.     end;
  289.     if (n<1) or (n>numgfiles) then writeln ('Invalid number.')
  290.       else getgfilenum:=n
  291.   end;
  292.  
  293.   procedure AddFile (gf:gfileRec);
  294.   begin
  295.     Seekgfile (Numgfiles+1);
  296.     write (gfile,gf)
  297.   end;
  298.  
  299.   function getfsize (filename:anystr):real;
  300.   var df:file of byte;
  301.   begin
  302.     gf.filesize:=-1;
  303.     assign (df,filename);
  304.     reset (df);
  305.     if ioresult<>0 then exit;
  306.     getfsize:=longfilesize(df);
  307.     close(df)
  308.   end;
  309.  
  310.   const beenaborted:boolean=false;
  311.  
  312.   function Aborted:boolean;
  313.   begin
  314.     if beenaborted then begin
  315.       aborted:=true;
  316.       exit
  317.     end;
  318.     aborted:=xpressed or hungupon;
  319.     if xpressed then begin
  320.       beenaborted:=true;
  321.       writeln (^B'New-scan aborted..')
  322.     end
  323.   end;
  324.  
  325.   procedure NewScan;
  326.   var cnt:integer;
  327.       first:integer;
  328.       newest:boolean;
  329.   label notlater;
  330.   begin
  331.     newest:=false;
  332.     beenaborted:=false;
  333.     first:=0;
  334.     for cnt:=filesize(gfile) downto 1 do begin
  335.       Seekgfile (cnt);
  336.       read (gfile,gf);
  337.       if later (datestr(gf.when),timestr(gf.when),datestr(laston),timestr(laston))
  338.         then first:=cnt
  339.         else goto notlater
  340.     end;
  341.     notlater:
  342.     if first<>0 then begin
  343.       writeln;
  344.       writeln (^M'G-File Area: ['^S+gfa.name+^R']');
  345.       for cnt:=first to filesize(gfile) do begin
  346.         if aborted then exit;
  347.         fastlistfile (cnt);
  348.       end
  349.     end
  350.   end;
  351.  
  352.   procedure SetArea (n:integer);
  353.   var otay:boolean;
  354.   begin
  355.     curarea:=n;
  356.     otay:=false;
  357.     if (n>numareas) or (n<1) then begin
  358.       writeln (^B'Invalid Area!');
  359.       if issysop then if makearea then setarea (curarea)
  360.         else setarea (1)
  361.       else setarea (1);
  362.       exit
  363.     end;
  364.     seekgfilea (n);
  365.     read (gfilea,gfa);
  366.     otay:=(urec.gfLevel>=gfa.Level);
  367.     if not otay then
  368.       if curarea=1 then error ('Access Level too low!','','')
  369.         else begin
  370.           reqlevel (gfa.level);
  371.           setarea (1);
  372.           exit
  373.         end;                     
  374.     Assigngf(n);
  375.     close (gfile);
  376.     reset (gfile);
  377.     if ioresult<>0 then rewrite (gfile);
  378.     if showit then writeln (^B^M'G-File Area: '^S,gfa.name,^R' ['^S,curarea,^R']');
  379.     if showit=false then writeln;
  380.   end;
  381.  
  382.   procedure newscanall;
  383.   var cnt:integer;
  384.       otay:boolean;
  385.   begin
  386.     writehdr ('New-Scanning,  Press [X] to abort.');
  387.     if aborted then exit;
  388.     for cnt:=1 to filesize(gfilea) do begin
  389.       seekgfilea (cnt);
  390.       read (gfilea,gfa);
  391.       otay:=false;
  392.       if urec.gfLevel>=gfa.Level then otay:=true;
  393.       if otay then begin
  394.         if aborted then exit;
  395.         { showit:=true; }
  396.         setarea (cnt);
  397.         { showit:=false; }
  398.         if aborted then exit;
  399.         newscan;
  400.       end;
  401.       if aborted then exit
  402.     end;
  403.   end;
  404.  
  405.   procedure listareas;
  406.   var cnt,old:integer;
  407.         gfatmp:gfilearea;
  408.   begin
  409.     writehdr ('Area List');
  410.     old:=curarea;
  411.     seekgfileA (1);
  412.     writeln(^M'Num Level   Name');
  413.     for cnt:=1 to NumAreas do begin
  414.       read (gfilea,gfatmp);
  415.       if (urec.level>=gfatmp.Level) then begin
  416.         write (^R,cnt:2,'. ['^S);
  417.          tab(strr(gfatmp.Level),5);
  418.         writeln(^R'] '^S,gfatmp.Name,^R);
  419.         if break then begin
  420.           setarea(old);
  421.           exit;
  422.         end;
  423.       end;
  424.     end;
  425.   { writeln;
  426.     setarea(old); }
  427.   end;
  428.  
  429.   function GetAreaNum:integer;
  430.   var areastr:sstr;
  431.       areanum:integer;
  432.   begin
  433.     getareanum:=0;
  434.     if length(input)>1 then areastr:=copy(input,2,255) else
  435.     begin
  436.     repeat
  437.       listareas;
  438.       writestr (^M'Area Number [?/List]:');
  439.       if input='!' then listareas else areastr:=input
  440.     until (input<>'?') or hungupon;
  441.     end;
  442.     if length(areastr)=0 then exit;
  443.     areanum:=valu(areastr);
  444.     if (areanum>0) and (areanum<=NumAreas) then getareanum:=areanum
  445.     else begin
  446.       writestr ('No such Area!');
  447.       if issysop then if makearea then getareanum:=numareas
  448.     end;
  449.   end;
  450.  
  451.   procedure GetArea;
  452.   var areanum:integer;
  453.   begin
  454.     areanum:=getareanum;
  455.     if areanum<>0 then SetArea (areanum);
  456.   end;
  457.  
  458.   procedure yourgfstatus;
  459.   begin
  460.   writeln (^B'╒══════════════════════════════════╕');
  461.     write ('│ G-File Level:     '^S);
  462.     tab (strr(urec.gflevel),15);
  463.     writeln (^R'│');
  464.     write ('│ G-File Uploads:   '^S);
  465.     tab (strr(urec.gfuploads),15);
  466.     writeln (^R'│');
  467.     write ('│ G-File Downloads: '^S);
  468.     tab (strr(urec.gfdownloads),15);
  469.     writeln (^R'│');
  470.     if useqr then begin
  471.      calcqr;
  472.      write (^R'│ Quality Rating:   '^S);
  473.      tab (strr(qr),15);
  474.      writeln (^R'│');
  475.     end;
  476.     writeln (^B'╘══════════════════════════════════╛');
  477.   end;
  478.  
  479.   procedure showgfile (n:integer);
  480.   var f:file;
  481.       protop,tran,fn:lstr;
  482.       b:integer;
  483.       ascii,crcmode,ymodem:boolean;
  484.       mm,mmmm:minuterec;
  485.       extrnproto:char;
  486.   begin
  487.     ascii:=false;
  488.     seekgfile (n);
  489.     read (gfile,gf);
  490.     if ulvl<0 then  exit;
  491.     writeln;
  492.     if useqr then begin
  493.      calcqr;
  494.      if (qr<qrlimit) and (ulvl<qrexempt) then begin
  495.      writeln ('Your Quality Rating is '^S+strr(qr)+^R'.');
  496.      writeln ('That exceeds the limit of '^S+strr(qrlimit)+^R'!');
  497.      writeln ('You must get a better QR before you can download.');
  498.      exit;
  499.     end;
  500.     end;
  501.     if not exist(getfname(gf.path,gf.fname)) then begin
  502.       writeln('File is [Offline]!');
  503.       writeln;
  504.       exit;
  505.     end;
  506.     writeln (^S'           - G-File Xfer Protocols -'^R);
  507.     writeln;
  508.     writeln (^R' ['^S'A'^R']-Ascii (Text Capture)');
  509.     writeln (^R' ['^S'X'^R']-Xmodem            ['^S'Y'^R']-Ymodem ');
  510.     writeln (^R' ['^S'Z'^R']-Zmodem            ['^S'J'^R']-Jmodem');
  511.     writeln (^R' ['^S'L'^R']-Lynx             '^S'*'^R'['^S'G'^R']-Ymodem-G');
  512.     writeln (^R' ['^S'S'^R']-Super8k           ['^S'K'^R']-K9Xmodem');
  513.     writeln (^R' ['^S'R'^R']-Zmodem Recovery   ['^S'P'^R']-PCPursuit Zmodem');
  514.     writeln (^S'*'^R'['^S'O'^R']-Xmodem OvrThrust '^S'*'^R'['^S'1'^R']-Ymodem OvrThrust');
  515.     writeln (^S' * = '^R'Registered DSZ required');
  516.     writeln;
  517.     if hungupon then exit;
  518.     protop:='';
  519.     writestr ('Protocol [Q/Quit][CR/Ascii]:');
  520.     if hungupon then exit;
  521.     tran:=input;
  522.     if (length(tran)=0) or (upcase(tran[1])='A') then begin
  523.      ascii:=true;
  524.      extrnproto:='N';
  525.     end;
  526.     if not ascii then begin
  527.     case upcase(tran[1]) of
  528.      'X' : ymodem:=false;
  529.      'Y' : ymodem:=true;
  530.      'Z' : extrnproto:='Z';
  531.      'J' : extrnproto:='J';
  532.      'L' : extrnproto:='L';
  533.      'G' : extrnproto:='G';
  534.      'O' : extrnproto:='O';
  535.      '1' : extrnproto:='1';
  536.      'S' : extrnproto:='S';
  537.      'K' : extrnproto:='K';
  538.      'R' : extrnproto:='R';
  539.      'P' : extrnproto:='P';
  540.      'Q' : exit;
  541.     end;
  542.     end;
  543.     fn:=getfname (gf.path,gf.fname);
  544.     if (extrnproto='N') and (not ascii) then crcmode:=true;
  545.     if tempsysop then begin
  546.       ulvl:=regularlevel;
  547.       tempsysop:=false;
  548.       writeurec;
  549.       bottomline
  550.     end;
  551.     starttimer (mm);
  552.     if (extrnproto='N') and (not ascii) then begin
  553.       if asciigraphics in urec.config then write ('■') else
  554.       write ('*');
  555.       writeln (' Send ready');
  556.       b:=protocolxfer (true,false,ymodem,fn);
  557.       beepbeep (b)
  558.     end;
  559.     if (extrnproto<>'N') and (not ascii) then begin
  560.       if extrnproto='Z' then writeln (^M'Use the -Z option for RLE compression!');
  561.       writeln ('■ Send ready');
  562.       b:=doext('S',extrnproto,gf.path,gf.fname,baudrate,usecom);
  563.       modeminlock:=false;
  564.       modemoutlock:=false;
  565.       beepbeep (b)
  566.     end;
  567.     stoptimer (mm);
  568.     if ascii then begin
  569.      starttimer (mmmm);
  570.      writestr('Press [X] to Abort or [CR] to Continue: *');
  571.      if upcase(input[1])='X' then exit;
  572.      writeln (^M^R'Title: '^S,gf.gfiledescr,
  573.               ^M^R'Date:  '^S,datestr (gf.when),
  574.               ^M^R'Time:  '^S,timestr (gf.when),^M);
  575.      printfile (getfname(gf.path,gf.Fname));
  576.      urec.gfdownloads:=urec.gfdownloads+1;
  577.      writeln (asciidownload);
  578.      writeln;
  579.      stoptimer (mmmm);
  580.     end;
  581.   end;
  582.  
  583.   procedure makeasciigfile (filename:anystr);
  584.   var t:text;
  585.       b:boolean;
  586.       yo:integer;
  587.       fname:lstr;
  588.   begin
  589.    assign (t,filename);
  590.    rewrite (t);
  591.    writeln;
  592.    if (asciigraphics in urec.config) then
  593.    writeln ('──────────────────────────────────────────────────────────') else
  594.    writeln ('----------------------------------------------------------');
  595.    writeln ('[Enter G-File now (Echo''d) - Type /S to Save, /A to Abort]');
  596.    if (asciigraphics in urec.config) then
  597.    writeln ('──────────────────────────────────────────────────────────') else
  598.    writeln ('----------------------------------------------------------');
  599.    writeln;
  600.    repeat
  601.     lastprompt:='Continue...'^M;
  602.     wordwrap:=true;
  603.     getstr (1);
  604.     b:=match(input,'/S') or match(input,'/A');
  605.     if not b then writeln (t,input)
  606.    until b;
  607.    textclose (t);
  608.    if match(input,'/A') then erase (t);
  609.    writelog (3,2,Filename);
  610. end;
  611.  
  612.   procedure uploadgfile;
  613.   var tx,t:text;
  614.       ascii,crcmode,bbb:boolean;
  615.       yo:integer;
  616.       fname,tran,protop,fn:lstr;
  617.       extrnproto:char;
  618.       emmemm:minuterec;
  619.   begin
  620.     writeln;
  621.     crcmode:=false;
  622.     ymodem:=false;
  623.     if gfa.upable=false then begin
  624.      writeln ('Sorry, Uploading is not allowed in this area!');
  625.      writeln;
  626.      exit;
  627.     end;
  628.     repeat
  629.      writestr ('Enter Upload Filename: *');
  630.      if length(input)=0 then exit;
  631.     until validfname (input);
  632.     gf.fname:=input;
  633.     fn:=getfname(gfa.gfiledir,gf.fname);
  634.     if not exist(fn) then begin
  635.      writestr ('Description: &');
  636.      gf.gfiledescr:=input;
  637.      assign (tx,fn);
  638.      writeln (^S'        G-File Xfer Protocols'^R);
  639.      writeln;
  640.      writeln (^R' ['^S'A'^R']-Ascii (Text Capture)');
  641.      writeln (^R' ['^S'X'^R']-Xmodem            ['^S'Y'^R']-Ymodem ');
  642.      writeln (^R' ['^S'Z'^R']-Zmodem            ['^S'J'^R']-Jmodem');
  643.      writeln (^R' ['^S'L'^R']-Lynx             '^S'*'^R'['^S'G'^R']-Ymodem-G');
  644.      writeln (^R' ['^S'S'^R']-Super8k           ['^S'K'^R']-K9Xmodem');
  645.      writeln (^R' ['^S'R'^R']-Zmodem Recovery   ['^S'P'^R']-PCPursuit Zmodem');
  646.      writeln (^S'*'^R'['^S'O'^R']-Xmodem OvrThrust '^S'*'^R'['^S'1'^R']-Ymodem OvrThrust');
  647.      writeln (^R' ['^S'E'^R']-Lynx Recovery     ');
  648.      writeln (^S' * = '^R'Registered DSZ required');
  649.      writeln;
  650.     if hungupon then exit;
  651.     protop:='';
  652.     writestr ('Protocol [Q/Quit][CR/Ascii]:');
  653.     if hungupon then exit;
  654.     tran:=input;
  655.     if (length(tran)=0) or (upcase(tran[1])='A') then begin
  656.      ascii:=true;
  657.      extrnproto:='N';
  658.     end else ascii:=false;
  659.     if not ascii then begin
  660.     case upcase(tran[1]) of
  661.      'X' : ymodem:=false;
  662.      'Y' : ymodem:=true;
  663.      'Z' : extrnproto:='Z';
  664.      'J' : extrnproto:='J';
  665.      'L' : extrnproto:='L';
  666.      'G' : extrnproto:='G';
  667.      'O' : extrnproto:='O';
  668.      '1' : extrnproto:='1';
  669.      'S' : extrnproto:='S';
  670.      'K' : extrnproto:='K';
  671.      'R' : extrnproto:='R';
  672.      'P' : extrnproto:='P';
  673.      'E' : extrnproto:='E';
  674.      'Q' : exit;
  675.     end;
  676.     end;
  677.     if (extrnproto='N') and (not ascii) then crcmode:=true;
  678.     if tempsysop then begin
  679.       ulvl:=regularlevel;
  680.       tempsysop:=false;
  681.       writeurec;
  682.       bottomline
  683.     end;
  684.     starttimer (emmemm);
  685.     if (extrnproto='N') and (not ascii) then begin
  686.       if asciigraphics in urec.config then write ('■') else write ('*');
  687.       writeln (' Receive ready');
  688.       yo:=protocolxfer (false,crcmode,ymodem,fn);
  689.       beepbeep (yo)
  690.     end;
  691.     if (extrnproto<>'N') and (not ascii) then begin
  692.       if extrnproto='Z' then begin
  693.        writeln (^M'Zmodem RLE compression being enabled!');
  694.        extrnproto:='^';
  695.       end;
  696.       writeln ('■ Receive ready');
  697.       yo:=doext('R',extrnproto,gf.path,gf.fname,baudrate,usecom);
  698.       modeminlock:=false;
  699.       modemoutlock:=false;
  700.       beepbeep (yo)
  701.     end;
  702.     if (not ascii) and (yo=0) then writelog (3,2,fn);
  703.     if (not ascii) and (yo>0) then begin
  704.      assign (tx,fn);
  705.      erase (tx);
  706.     end;
  707.     if ascii then begin
  708.      assign (t,fn);
  709.      rewrite (t);
  710.      writeln;
  711.      if (asciigraphics in urec.config) then
  712.      writeln ('───────────────────────────────────────────────────────') else
  713.      writeln ('-------------------------------------------------------');
  714.      writeln ('Enter G-File now (Echo''d) - [/S] to Save, [/A] to Abort');
  715.      if (asciigraphics in urec.config) then
  716.      writeln ('───────────────────────────────────────────────────────') else
  717.      writeln ('-------------------------------------------------------');
  718.      writeln;
  719.      repeat
  720.       lastprompt:='Continue...'^M;
  721.       wordwrap:=true;
  722.       getstr (1);
  723.       bbb:=match(input,'/S') or match(input,'/A');
  724.       if not bbb then begin
  725.        writeln (t,input);
  726.       end;
  727.      until bbb;
  728.      textclose (t);
  729.      if match(input,'/A') then erase (t);
  730.      writelog (3,2,fn);
  731.     end
  732.     end else writeln (^M'File exists!'^M);
  733.     stoptimer (emmemm);
  734.     writeln;
  735.     if not exist (fn) then begin
  736.      writeln ('Upload Aborted!');
  737.      exit;
  738.     end else writeln ('Thanks for the upload!');
  739.     gf.when:=now;
  740.     gf.sentby:=unam;
  741.     gf.path:=gfa.gfiledir;
  742.     gf.downloaded:=0;
  743.     gf.specialfile:=false;
  744.     gf.newfile:=true;
  745.     gf.filesize:=getfsize (fn);
  746.     urec.gfuploads:=urec.gfuploads+1;
  747.     seekgfile (numgfiles+1);
  748.     write (gfile,gf);
  749.     if gfilez>32760 then gfilez:=0;
  750.     gfilez:=gfilez+1;
  751.     writeln;
  752.     writelog (3,10,gf.gfileDescr)
  753. end;
  754.  
  755.   procedure SysopCommands;
  756.   var q:integer;
  757.  
  758.     procedure getstr (prompt:mstr; var ss; len:integer);
  759.     var a:anystr absolute ss;
  760.     begin
  761.       writeln (^B^M'Current ',prompt,' is: '^S,a);
  762.       buflen:=len;
  763.       writestr ('Enter new '+prompt+':');
  764.       if length(input)>0 then a:=input;
  765.     end;
  766.  
  767.     procedure getint (prompt:mstr; var i:integer);
  768.     var q:sstr;
  769.         n:integer;
  770.     begin
  771.       str (i,q);
  772.       getstr (prompt,q,5);
  773.       n:=valu (q);
  774.       if n<>0 then i:=n
  775.     end;
  776.  
  777.     procedure getboo (t:lstr; var b:boolean);
  778.     var s:sstr;
  779.     begin
  780.       s:=yesno (b);
  781.       getstr (t,s,1);
  782.       b:=upcase(s[1])='Y'
  783.     end;
  784.  
  785.     procedure RemoveFile (n:integer);
  786.     var cnt:integer;
  787.     begin
  788.       for cnt:=n to numgfiles-1 do begin
  789.         seekgfile (cnt+1);
  790.         read (gfile,gf);
  791.         seekgfile (cnt);
  792.         write (gfile,gf)
  793.       end;
  794.       seekgfile (numgfiles);
  795.       truncate (gfile)
  796.     end;
  797.  
  798.     procedure Addgfile;
  799.     var fn:Anystr;
  800.     begin
  801.       writestr ('Filename: *');
  802.       if length(input)=0 then exit;
  803.       gf.fname:=input;
  804.       Writestr ('Path [CR/'+gfa.gfileDir+']: *');
  805.       if length(input)=0 then Input:=gfa.gfileDir;
  806.       gf.path:=input;
  807.       begin
  808.         fn:=getfname(gf.path,gf.fname);
  809.         if not exist(fn) then begin
  810.           writestr ('File not found!  Enter file now [y/n]? *');
  811.           if yes then makeasciigfile(fn)
  812.         end;
  813.         if not exist(fn) then exit;
  814.       end;
  815.       writestr ('Description:');
  816.       if length(input)=0 then exit;
  817.       gf.gfiledescr:=input;
  818.       writestr ('Sent by [CR/'+unam+']:');
  819.       if length(input)=0 then input:=unam;
  820.       gf.sentby:=input;
  821.       gf.filesize:=getfsize(fn);
  822.       gf.when:=now;
  823.       gf.Downloaded:=0;
  824.       gf.SpecialFile:=False;
  825.       gf.NewFile:=False;
  826.       seekgfile (numgfiles+1);
  827.       write (gfile,gf);
  828.       if gfilez>32760 then gfilez:=0;
  829.       gfilez:=gfilez+1;
  830.       if urec.lastgfiles>32760 then urec.lastgfiles:=0;
  831.       urec.lastgfiles:=urec.lastgfiles+1;
  832.       urec.gfuploads:=urec.gfuploads+1;
  833.       writelog (3,11,gf.gfiledescr);
  834.       writeurec
  835.     end;
  836.  
  837.     procedure Editgfile;
  838.     var n:integer;
  839.         fn:anystr;
  840.     begin
  841.       n:=getgfilenum('edit');
  842.       if n=0 then exit;
  843.       seekgfile (n);
  844.       read (gfile,gf);
  845.       getstr ('Filename',gf.fname,12);
  846.       getstr ('Path',gf.path,50);
  847.         fn:=Getfname(gf.path,gf.fname);
  848.         if not exist (fn) then begin
  849.           write (^B^M,fn,' not found!');
  850.           writestr (^M'Create new file '+fn+'? *');
  851.           if yes then makeasciigfile(fn);
  852.           if not exist(fn) then exit;
  853.         end else gf.Filesize:=GetFsize(fn);
  854.       getstr ('Description',gf.gfileDescr,75);
  855.       getstr ('Uploader',gf.Sentby,28);
  856.       getboo ('Special File',gf.SpecialFile);
  857.       getboo ('New file',gf.NewFile);
  858.       seekgfile (n);
  859.       write (gfile,gf);
  860.       writelog (3,3,gf.gfileDescr);
  861.     end;
  862.  
  863.     procedure killgarea;
  864.     var gfatmp:gfilearea;
  865.         cnt,n:integer;
  866.         oldname,newname:sstr;
  867.     begin
  868.       gfatmp:=gfa;
  869.       writestr ('Delete Area #'+strr(curarea)+' ['+gfatmp.Name+']: *');
  870.       if not yes then exit;
  871.       gfilez:=gfilez-numgfiles;
  872.       urec.lastgfiles:=urec.lastgfiles-numgfiles;
  873.       if gfilez<0 then gfilez:=0;
  874.       if urec.lastgfiles<0 then urec.lastgfiles:=0;
  875.       close (gfile);
  876.       oldname:=uploaddir+'gfile'+strr(curarea);
  877.       assign (gfile,oldname);
  878.       erase (gfile);
  879.       for cnt:=curarea to NumAreas-1 do begin
  880.         newname:=oldname;
  881.         oldname:=uploaddir+'gfile'+strr(cnt+1);
  882.         assign (gfile,oldname);
  883.         rename (gfile,newname);
  884.         n:=ioresult;
  885.         Seekgfilea (cnt+1);
  886.         read (gfilea,gfatmp);
  887.         seekgfilea (cnt);
  888.         write (gfilea,gfatmp);
  889.       end;
  890.       seekgfilea (numareas);
  891.       truncate (gfilea);
  892.       setarea (1)
  893.     end;
  894.  
  895.     procedure ModGArea;
  896.     var gfatmp:gfilearea;
  897.     begin
  898.       gfatmp:=gfa;
  899.       getstr ('Area Name',gfatmp.Name,80);
  900.       getint ('Access Level',gfatmp.Level);
  901.       getstr ('Sponsor',gfatmp.Sponsor,30);
  902.       getboo ('"Able to upload here"',gfatmp.UpAble);
  903.       getstr ('Upload Dir',gfatmp.gfileDir,50);
  904.       seekgfilea (curarea);
  905.       write (gfilea,gfatmp);
  906.       gfa:=gfatmp;
  907.     end;
  908.  
  909.     procedure deletegfile;
  910.     var cnt,n,anarky:integer;
  911.         f:file;
  912.         gfn:lstr;
  913.         floyd:userrec;
  914.     begin
  915.       n:=getgfilenum ('Delete');
  916.       if n=0 then exit;
  917.       seekgfile (n);
  918.       read (gfile,gf);
  919.       gfn:=getfname(gf.path,gf.fname);
  920.       gfn:=upstring(gfn);
  921.       writeln;
  922.       writehdr ('Delete G-File');
  923.       writeln (^R'Filename:    '^S,gfn);
  924.       writeln (^R'Size:        '^S,streal(gf.filesize));
  925.       writeln (^R'Description: '^S,gf.gfiledescr);
  926.       writeln (^R'Uploader:    '^S,gf.sentby);
  927.       writeln (^R);
  928.       writestr ('Delete this [y/n]? *');
  929.       if not yes then exit;
  930.       writestr ('Erase Disk File '+gfn+'? *');
  931.       if yes then begin
  932.         assign (f,getfname(gf.path,gf.fname));
  933.         erase (f);
  934.         if ioresult<>0 then writestr ('Couldn''t erase File.')
  935.       end;
  936.       for cnt:=n+1 to numgfiles do begin
  937.         seekgfile (cnt);
  938.         read (gfile,gf);
  939.         seekgfile (cnt-1);
  940.         write (gfile,gf)
  941.       end;
  942.       seekgfile (numgfiles);
  943.       truncate (gfile);
  944.       if gfilez<0 then gfilez:=0;
  945.       gfilez:=gfilez-1;
  946.       if urec.lastgfiles<0 then urec.lastgfiles:=0;
  947.       urec.lastgfiles:=urec.lastgfiles-1;
  948.       writeurec;
  949.       writestr ('Remove Upload Credits from uploader [y/n]? *');
  950.       if yes then begin
  951.        anarky:=lookupuser (gf.sentby);
  952.        if anarky<>0 then begin
  953.         writeurec;
  954.         seek (ufile,anarky);
  955.         read (ufile,floyd);
  956.         floyd.gfuploads:=floyd.gfuploads-1;
  957.         seek (ufile,anarky);
  958.         write (ufile,floyd);
  959.         readurec
  960.        end;
  961.       end;
  962.       writestr (^M'Deleted.');
  963.       writelog (3,4,gf.gfileDescr)
  964.     end;
  965.  
  966.     procedure Updategfile;
  967.     var n:integer;
  968.     begin
  969.       n:=GetgfileNum('update');
  970.       if n=0 then exit;
  971.       seekgfile (n);
  972.       read (gfile,gf);
  973.       gf.when:=now;
  974.       gf.filesize:=getfsize(getfname(gf.path,gf.fname));
  975.       seekgfile (n);
  976.       write (gfile,gf);
  977.       writelog (3,5,gf.gfileDescr)
  978.     end;
  979.  
  980.     procedure SortGArea;
  981.     var temp,mark,cnt,method:integer;
  982.         v1,v2:string[80];
  983.         gftmp:gfileRec;
  984.     begin
  985.       writehdr ('Sort G-Files');
  986.       writeln;
  987.       writeln ('[0]:Quit');
  988.       writeln ('[1]:Description');
  989.       writeln ('[2]:Filename');
  990.       writeln;
  991.       writestr ('Enter method: *');
  992.       method:=valu(input[1]);
  993.       if method=0 then exit;
  994.       mark:=numgfiles-1;
  995.       repeat
  996.         if mark<>0 then begin
  997.           temp:=mark;
  998.           mark:=0;
  999.           for cnt:=1 to temp do begin
  1000.             seekgfile (cnt);
  1001.             read (gfile,gf);
  1002.             read (gfile,gftmp);
  1003.             if method=1 then begin
  1004.               v1:=upstring(gf.gfileDescr);
  1005.               v2:=upstring(gftmp.gfileDescr);
  1006.             end else begin
  1007.               v1:=upstring(gf.fname);
  1008.               v2:=upstring(gftmp.fname);
  1009.             end;
  1010.             if v1>v2 then begin
  1011.               mark:=cnt;
  1012.               seekgfile (cnt);
  1013.               write (gfile,gftmp);
  1014.               write (gfile,gf)
  1015.             end
  1016.           end
  1017.         end
  1018.       until mark=0
  1019.     end;
  1020.  
  1021.     procedure ReorderGAreas;
  1022.     var cura,newa:integer;
  1023.         gfatmp:gfilearea;
  1024.         f1,f2:file;
  1025.         fn1,fn2:sstr;
  1026.     label exit;
  1027.     begin
  1028.       writehdr ('Reorder G-File Areas');
  1029.       writeln (^M'Number of G-File areas: ',numareas:1);
  1030.       for cura:=0 to numareas-2 do begin
  1031.         repeat
  1032.           writestr (^M^J+'New Area #'+strr(cura+1)+' [?/List]:[CR/Quit]:');
  1033.           if length(input)=0 then goto exit;
  1034.           if input='?' then begin
  1035.             listareas;
  1036.             newa:=-1
  1037.           end else begin
  1038.             newa:=valu(input)-1;
  1039.             if (newa<0) or (newa>=numareas) then begin
  1040.               writeln ('Not found!  Please re-enter...');
  1041.               newa:=-1
  1042.             end
  1043.           end
  1044.         until (newa>0);
  1045.         seek (gfilea,cura);
  1046.         read (gfilea,gfa);
  1047.         seek (gfilea,newa);
  1048.         read (gfilea,gfatmp);
  1049.         seek (gfilea,cura);
  1050.         write (gfilea,gfatmp);
  1051.         seek (gfilea,newa);
  1052.         write (gfilea,gfa);
  1053.         fn1:=uploaddir+'gfile';
  1054.         fn2:=fn1+strr(newa+1);
  1055.         fn1:=fn1+strr(cura+1);
  1056.         assign (f1,fn1);
  1057.         assign (f2,fn2);
  1058.         rename (f1,'Temp$$$$.%%%');
  1059.         rename (f2,fn1);
  1060.         rename (f1,fn2)
  1061.       end;
  1062.       exit:
  1063.       setarea (1)
  1064.     end;
  1065.  
  1066.     procedure Movegfile;
  1067.     var an,fn,old:integer;
  1068.         newfilesam,sambam,filesam,wangbang:anystr;
  1069.         darn:file;
  1070.         gftmp:gfileRec;
  1071.     begin
  1072.       fn:=GetgfileNum ('move');
  1073.       old:=curarea;
  1074.       if fn=0 then exit;
  1075.       input:='';
  1076.       an:=GetAreaNum;
  1077.       if an=0 then exit;
  1078.       Seekgfile (fn);
  1079.       read (gfile,gftmp);
  1080.       removefile (fn);
  1081.       writestr('Physically move the file to correct area? *');
  1082.       write ('Moving...');
  1083.       filesam:=Getfname(gftmp.path,gftmp.fname);
  1084.       sambam:=gftmp.path;
  1085.       setarea(an);
  1086.       if (sambam<>gfa.gfileDir) then if yes then begin
  1087.         gftmp.path:=gfa.gfileDir;
  1088.         newfilesam:=Getfname(gftmp.path,gftmp.fname);
  1089.         exec('Copy',' '+filesam+' '+newfilesam+' >temp');
  1090.         wangbang:=filesam;
  1091.         assign(darn,wangbang);
  1092.         if exist(newfilesam) then erase (darn) else begin
  1093.           gftmp.path:=sambam;
  1094.           writeln('Uh oh... Bad error!');
  1095.         end;
  1096.       end;
  1097.       setarea (An);
  1098.       Addfile (gftmp);
  1099.       setarea (old);
  1100.       writeln (^B'Done.')
  1101.     end;
  1102.  
  1103.   procedure getpathname (fname:lstr; var path:lstr; var name:sstr);
  1104.   var p:integer;
  1105.   begin
  1106.     path:='';
  1107.     repeat
  1108.       p:=pos('\',fname);
  1109.       if p<>0 then begin
  1110.         path:=path+copy(fname,1,p);
  1111.         fname:=copy(fname,p+1,255)
  1112.       end
  1113.     until p=0;
  1114.     name:=fname
  1115.   end;
  1116.  
  1117.   procedure displayfile (var ffinfo:searchrec);
  1118.   var a:integer;
  1119.   begin
  1120.     a:=ffinfo.attr;
  1121.     if (a and 8)=8 then exit;
  1122.     tab (ffinfo.name,13);
  1123.     if (a and 16)=16
  1124.       then write ('Directory')
  1125.       else write (ffinfo.size);
  1126.     if (a and 1)=1 then write (' <read-only>');
  1127.     if (a and 2)=2 then write (' <hidden>');
  1128.     if (a and 4)=4 then write (' <system>');
  1129.     writeln
  1130.   end;
  1131.  
  1132.   procedure getfsize (var g:gfilerec);
  1133.   var df:file of byte;
  1134.   begin
  1135.     g.filesize:=-1;
  1136.     assign (df,getfname(g.path,g.fname));
  1137.     reset (df);
  1138.     if ioresult<>0 then exit;
  1139.     g.filesize:=filesize(df);
  1140.     close(df)
  1141.   end;
  1142.  
  1143.   procedure addresidentgfile (fname:lstr);
  1144.   var g:gfilerec;
  1145.       fn:anystr;
  1146.   begin
  1147.     getpathname (fname,g.path,g.fname);
  1148.     getfsize(g);
  1149.     if g.filesize=-1 then begin
  1150.       writeln ('File can''t be opened!');
  1151.       exit
  1152.     end;
  1153.       writestr ('Description: &');
  1154.       g.gfiledescr:=input;
  1155.       getfsize(g);
  1156.       g.when:=now;
  1157.       g.sentby:=unam;
  1158.       g.downloaded:=0;
  1159.       g.specialfile:=False;
  1160.       g.newfile:=False;
  1161.       seekgfile (numgfiles+1);
  1162.       write (gfile,g);
  1163.       gfilez:=gfilez+1;
  1164.       writeln;
  1165.       writelog (3,11,g.gfiledescr)
  1166.   end;
  1167.  
  1168.   procedure addmultiplegfiles;
  1169.   var spath,pathpart:lstr;
  1170.       dummy:sstr;
  1171.       f:file;
  1172.       ffinfo:searchrec;
  1173.   begin
  1174.     if ulvl<sysoplevel then begin
  1175.       writeln (
  1176.         'Sorry, you may not add resident files without true sysop access!');
  1177.       exit
  1178.     end;
  1179.     writehdr ('Add Resident G-Files By Wildcard');
  1180.     writestr ('Search path/wildcard:');
  1181.     if length(input)=0 then exit;
  1182.     spath:=input;
  1183.     if spath[length(spath)]='\' then dec(spath[0]);
  1184.     assign (f,spath+'\con');
  1185.     reset (f);
  1186.     if ioresult=0 then begin
  1187.       close (f);
  1188.       spath:=spath+'\*.*'
  1189.     end;
  1190.     getpathname (spath,pathpart,dummy);
  1191.     findfirst (spath,$17,ffinfo);
  1192.     if doserror<>0
  1193.       then writeln ('No files found!')
  1194.       else
  1195.         while doserror=0 do begin
  1196.           writeln;
  1197.           displayfile (ffinfo);
  1198.           writestr ('Add this file [Y/N/X]? *');
  1199.           if yes
  1200.             then addresidentgfile (getfname(pathpart,ffinfo.name))
  1201.             else if (length(input)>0) and (upcase(input[1])='X')
  1202.               then exit;
  1203.           findnext (ffinfo)
  1204.         end
  1205.   end;
  1206.  
  1207.   function defaultdrive:byte;
  1208.   var r:registers;
  1209.   begin
  1210.     r.ah:=$19;
  1211.     intr ($21,r);
  1212.     defaultdrive:=r.al+1
  1213.   end;
  1214.  
  1215.   function unsigned (i:integer):real;
  1216.   begin
  1217.     if i>=0
  1218.       then unsigned:=i
  1219.       else unsigned:=65536.0+i
  1220.   end;
  1221.  
  1222.   procedure writefreespace (path:lstr);
  1223.   var drive:byte;
  1224.       r:registers;
  1225.       csize,free,total:real;
  1226.   begin
  1227.     r.ah:=$36;
  1228.     r.dl:=ord(upcase(path[1]))-64;
  1229.     intr ($21,r);
  1230.     if r.ax=-1 then begin
  1231.       writeln ('Invalid drive');
  1232.       exit
  1233.     end;
  1234.     csize:=unsigned(r.ax)*unsigned(r.cx);
  1235.     free:=csize*unsigned(r.bx);
  1236.     total:=csize*unsigned(r.dx);
  1237.     free:=free/1024;
  1238.     total:=total/1024;
  1239.     writeln (free:0:0,'k out of ',total:0:0,'k')
  1240.   end;
  1241.  
  1242.   procedure directory;
  1243.   var r:registers;
  1244.       ffinfo:searchrec;
  1245.       tpath:anystr;
  1246.       b:byte;
  1247.       cnt:integer;
  1248.   begin
  1249.     getdir (defaultdrive,tpath);
  1250.     if tpath[length(tpath)]<>'\' then tpath:=tpath+'\';
  1251.     tpath:=tpath+'*.*';
  1252.     writestr ('Path/Wildcard [CR for '+tpath+']:');
  1253.     writeln (^M);
  1254.     if length(input)<>0 then tpath:=input;
  1255.     writelog (16,10,tpath);
  1256.     findfirst (chr(defaultdrive+64)+':\*.*',8,ffinfo);
  1257.     if doserror<>0
  1258.       then writeln ('No volume label'^M)
  1259.       else writeln ('Volume label: ',ffinfo.name,^M);
  1260.     findfirst (tpath,$17,ffinfo);
  1261.     if doserror<>0 then writeln ('No files found.') else begin
  1262.       cnt:=0;
  1263.       while doserror=0 do begin
  1264.         cnt:=cnt+1;
  1265.         if not break then displayfile (ffinfo);
  1266.         findnext (ffinfo)
  1267.       end;
  1268.       writeln (^B^M'Total Files: ',cnt)
  1269.     end;
  1270.     write ('Free Disk Space: ');
  1271.     writefreespace (tpath)
  1272.   end;
  1273.  
  1274.   begin
  1275.     if not issysop then begin
  1276.       reqlevel (sysoplevel);
  1277.       exit
  1278.     end;
  1279.     repeat
  1280.       q:=menu ('G-File Sysop','SGFILE','QACDUKRMSOW@F`');
  1281.       case q of
  1282.         2:addgfile;
  1283.         3:editgfile;
  1284.         4:deletegfile;
  1285.         5:updategfile;
  1286.         6:killgarea;
  1287.         7:modgarea;
  1288.         8:movegfile;
  1289.         9:Sortgarea;
  1290.         10:reordergareas;
  1291.         11:addmultiplegfiles;
  1292.         12:directory;
  1293.         13:begin
  1294.             writestr ('Access Code: *');
  1295.             if not match (input,'G;G') then exit;
  1296.             writeln;
  1297.             writeln ('gfilez:',gfilez);
  1298.             writeln ('urec.lastgfiles:',urec.lastgfiles);
  1299.             writestr ('set gfilez/urec.lastgfiles to 0 [y/n]? *');
  1300.             if yes then begin
  1301.              gfilez:=0;
  1302.              urec.lastgfiles:=0;
  1303.             end;
  1304.             writestr ('urec.gfuploads ('+strr(urec.gfuploads)+'): &');
  1305.             if length(input)>0 then urec.gfuploads:=valu(input);
  1306.             writeurec;
  1307.            end;
  1308.       end
  1309.     until hungupon or (q=1)
  1310.   end;
  1311.  
  1312. var prompt:lstr;
  1313.     n:integer;
  1314.     k:char;
  1315.     q1:mstr;
  1316.     a:arearec;
  1317.     ms:boolean;
  1318.     dammit:boolean;
  1319.     q:integer;
  1320.     x1,x2,x3,zxcv1,zxcv2:integer;
  1321.     y1,y2,y3:real;
  1322. begin
  1323.   dammit:=false;
  1324.   showit:=true;
  1325.   writehdr ('G-Files Section');
  1326.   writeln;
  1327.   itsotay:=false;
  1328.   opengfile;
  1329.   if not itsotay then exit;
  1330.   seekgfilea(1);
  1331.   read (gfilea,gfa);
  1332.   if (urec.gfLevel<gfa.Level) then begin
  1333.     writeln('You don''t have access to the G-Files Section.');
  1334.     exit;
  1335.   end;
  1336.   x1:=urec.nbu;
  1337.   x2:=urec.numon;
  1338.   if x1<1 then x1:=1;
  1339.   if x2<1 then x2:=1;
  1340.   y1:=int(x1);
  1341.   y2:=int(x2);
  1342.   y1:=y1;
  1343.   y2:=y2;
  1344.   y3:=y1/y2;
  1345.   y3:=y3*100;
  1346.   x3:=trunc(y3);
  1347.   write (^R'Required Post/Call Ratio: ['^S);
  1348.   for zxcv1:=1 to 3-(length(strr(gfpcr))) do write (' ');
  1349.   write (strr(gfpcr));
  1350.   writeln ('%'^R']');
  1351.   write (^R'Your Post/Call Ratio:     ['^S);
  1352.   for zxcv2:=1 to 3-(length(strr(x3))) do write (' ');
  1353.   write (strr(x3));
  1354.   writeln ('%'^R']');
  1355.   writeln;
  1356.   write (^R'PCR Status: ['^S);
  1357.   if ulvl>=pcrexempt then write ('Exempt from PCR.') else
  1358.   if (x3<gfpcr) and (ulvl<pcrexempt) then write ('PCR too low!') else
  1359.   if (x3>=gfpcr) and (ulvl<pcrexempt) then write ('Passed PCR check.');
  1360.   writeln (^R']');
  1361.   writeln;
  1362.   if (x3<gfpcr) and (ulvl<pcrexempt) then begin
  1363.    writeln (^B^R'Your Posts-per-Call Ratio is too low!');
  1364.    writeln ('Go post a message or two.');
  1365.    close (gfile);
  1366.    close (gfilea);
  1367.    exit;
  1368.   end;
  1369.   yourgfstatus;
  1370.     setarea(1);
  1371.   repeat
  1372.     prompt:='';
  1373.     q:=menu ('G-Files Command','GFILE','QU%FAYNVDLG');
  1374.     case q of
  1375.       1:begin
  1376.           close(gfile);
  1377.           close(gfilea);
  1378.         end;
  1379.       2:uploadgfile;
  1380.       3:sysopcommands;
  1381.       4:fastlistgfiles;
  1382.       5:getarea;
  1383.       6:yourgfstatus;
  1384.       7:newscanall;
  1385.       8:newscan;
  1386.       9:begin
  1387.           n:=getgfilenum ('Download');
  1388.           if n>0 then showgfile(n);
  1389.         end;
  1390.       10:fastlistgfiles;
  1391.       11:offtcs;
  1392.     end;
  1393.   until hungupon or (q=1);
  1394. end;
  1395.  
  1396. begin
  1397. end.
  1398.