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

  1. {$R-,S-,I-,D-,F+,V-,B-,N- }
  2. {$M 65500,0,0 }
  3.  
  4. unit overret1;
  5.  
  6. interface
  7.  
  8. uses crt,
  9.      gentypes,modem,configrt,gensubs,subs1,subs2,userret,textret,flags,mainr1;
  10.  
  11. procedure help (fn:mstr);
  12. procedure edituser (eunum:integer);
  13. procedure printnews;
  14. procedure sendmodemstr (ss:anystr; endifcarrier:boolean);
  15. function getlastcaller:mstr;
  16. procedure showlastcallers;
  17. procedure infoform (i:integer);
  18. function selectspecs (var us:userspecsrec):boolean; { True if user aborts }
  19. procedure editoldspecs;
  20.  
  21. implementation
  22.  
  23. var buflen30:boolean;
  24.  
  25. procedure help (fn:mstr);
  26. var tf:text;
  27.     htopic,cnt:integer;
  28. begin
  29.   fn:=textfiledir+fn;
  30.   assign (tf,fn);
  31.   reset (tf);
  32.   if ioresult<>0 then begin
  33.     writestr ('Sorry, no help is availiable!');
  34.     if issysop then begin
  35.       writeln ('Sysop: To make help, create a file called ',fn);
  36.       writeln ('Group the lines into blocks separated by periods.');
  37.       writeln ('The first group is the topic menu; the second is the');
  38.       writeln ('help for topic 1; the third for topic 2; etc.')
  39.     end;
  40.     exit
  41.   end;
  42.   repeat
  43.     textclose (tf);
  44.     assign (tf,fn);
  45.     reset (tf);
  46.     writeln (^M);
  47.     printtexttopoint (tf);
  48.     repeat
  49.       writestr (^M'Topic Number [CR/Quit]:');
  50.       if hungupon or (length(input)=0) then
  51.         begin
  52.           textclose (tf);
  53.           exit
  54.         end;
  55.       htopic:=valu (input)
  56.     until (htopic>0);
  57.     for cnt:=2 to htopic do
  58.       if not eof(tf)
  59.         then skiptopoint (tf);
  60.     if eof(tf)
  61.       then writestr ('Sorry, no help on that topic!')
  62.       else printtexttopoint (tf)
  63.   until 0=1
  64. end;
  65.  
  66. procedure edituser (eunum:integer);
  67. var eurec:userrec;
  68.     ca:integer;
  69.     k:char;
  70. const sysopstr:array [false..true] of string[6]=('Normal','Sysop');
  71.       sectionnames:array [udsysop..gfsysop] of string[20]=
  72.         ('File transfer','Bulletin section','Voting booths',
  73.          'E-mail section','Doors','Main menu','Databases','Trivia','G-Files');
  74.  
  75.   procedure truesysops;
  76.   begin
  77.     writeln ('Sorry, you may not do that without true sysop access!');
  78.     writelog (18,17,'')
  79.   end;
  80.  
  81.   function truesysop:boolean;
  82.   begin
  83.     truesysop:=ulvl<>sysoplevel
  84.   end;
  85.  
  86.   procedure eustatus;
  87.   var cnt:integer;
  88.       k:char;
  89.       c:configtype;
  90.   begin
  91.     writehdr ('[ User Status ]');
  92.     with eurec do begin
  93.       write (^M'Number:    '^S,eunum,
  94.              ^M'Name:      '^S,handle,
  95.              ^M'Phone #:   '^S,phonenum,
  96.              ^M'Note:      '^S,note,
  97.              ^M'Pwd:       '^S);
  98.       if truesysop
  99.         then write (password)
  100.         else write ('[Classified]');
  101.       write (^M'Level:     '^S,level,
  102.              ^M'Last on:   '^S,datestr(laston),', at ',timestr(laston),
  103.              ^M'Posts:     '^S,nbu,
  104.              ^M'Uploads:   '^S,nup,
  105.              ^M'Downloads: '^S,ndn,
  106.              ^M'Wanted:    '^S,yesno(wanted in config),
  107.              ^M'File Xfer',
  108.              ^M'  Level:   '^S,udlevel,
  109.              ^M'  Points:  '^S,udpoints,
  110.              ^M'  Uploads: '^S,uploads,
  111.              ^M'  Dnloads: '^S,downloads,
  112.              ^M'G-Files',
  113.              ^M'  Level:   '^S,gflevel,
  114.              ^M'  Uploads: '^S,gfuploads,
  115.              ^M'  Dnloads: '^S,gfdownloads,
  116.            ^M^M'Time on system:  '^S,totaltime:0:0,
  117.              ^M'Number of calls: '^S,numon,
  118.              ^M'Voting record:   '^S);
  119.       for cnt:=1 to maxtopics do begin
  120.         if cnt<>1 then write (',');
  121.         write (voted[cnt])
  122.       end;
  123.       writeln (^M);
  124.       for c:=udsysop to databasesysop do
  125.         if c in eurec.config
  126.           then writeln (^B'Sysop of the '^S,sectionnames[c]);
  127.       writeln
  128.     end;
  129.     writelog (18,13,'')
  130.   end;
  131.  
  132.   procedure getmstr (t:mstr; var mm);
  133.   var m:mstr absolute mm;
  134.   begin
  135.     writeln ('Old ',t,': '^S,m);
  136.     if buflen30 then buflen:=30;
  137.     writestr ('New '+t+'? *');
  138.     if length(input)>0 then m:=input
  139.   end;
  140.  
  141.   procedure getsstr (t:mstr; var s:sstr);
  142.   var m:mstr;
  143.   begin
  144.     m:=s;
  145.     getmstr (t,m);
  146.     s:=m
  147.   end;
  148.  
  149.   procedure getint (t:mstr; var i:integer);
  150.   var m:mstr;
  151.   begin
  152.     m:=strr(i);
  153.     getmstr (t,m);
  154.     i:=valu(m)
  155.   end;
  156.  
  157.   procedure euwanted;
  158.   begin
  159.     writestr ('Wanted status: '^S+yesno(wanted in eurec.config));
  160.     writestr ('New wanted status:');
  161.     if yes
  162.       then eurec.config:=eurec.config+[wanted]
  163.       else eurec.config:=eurec.config-[wanted];
  164.     writelog (18,1,yesno(wanted in eurec.config))
  165.   end;
  166.  
  167.   procedure eudel;
  168.   begin
  169.     writestr ('KILL the lame fagget [y/n]? *');
  170.     if yes then begin
  171.       deleteuser (eunum);
  172.       seek (ufile,eunum);
  173.       read (ufile,eurec);
  174.       writelog (18,9,'')
  175.     end
  176.   end;
  177.  
  178.   procedure euname;
  179.   var m:mstr;
  180.   begin
  181.     m:=eurec.handle;
  182.     getmstr ('name',m);
  183.     if not match (m,eurec.handle) then
  184.       if lookupuser (m)<>0 then begin
  185.         writestr ('Already exists!  Are you sure [y/n]? *');
  186.         if not yes then exit
  187.       end;
  188.     eurec.handle:=m;
  189.     writelog (18,6,m)
  190.   end;
  191.  
  192.   procedure eupassword;
  193.   begin
  194.     if not truesysop
  195.       then truesysops
  196.       else begin
  197.         getsstr ('Password',eurec.password);
  198.         writelog (18,8,'')
  199.       end
  200.   end;
  201.  
  202.   procedure eulevel;
  203.   var n:integer;
  204.   begin
  205.     n:=eurec.level;
  206.     getint ('Level',n);
  207.     if (n>=sysoplevel) and (not truesysop)
  208.       then truesysops
  209.       else begin
  210.         eurec.level:=n;
  211.         writelog (18,15,strr(n))
  212.       end
  213.   end;
  214.  
  215.   procedure eugflevel;
  216.   var n:integer;
  217.   begin
  218.     n:=eurec.gflevel;
  219.     getint ('G-File Level',n);
  220.     if (n>=sysoplevel) and (not truesysop)
  221.       then truesysops
  222.       else begin
  223.         eurec.gflevel:=n;
  224.         writelog (18,18,strr(n))
  225.       end
  226.   end;
  227.  
  228.   procedure euphone;
  229.   var m:mstr;
  230.       p:integer;
  231.   begin
  232.     m:=eurec.phonenum;
  233.     buflen:=15;
  234.     getmstr ('Phone Number',m);
  235.     p:=1;
  236.     while p<=length(m) do
  237.       if (m[p] in ['0'..'9'])
  238.         then p:=p+1
  239.         else delete (m,p,1);
  240.     if length(m)>7 then begin
  241.       eurec.phonenum:=m;
  242.       writelog (18,16,m)
  243.     end
  244.   end;
  245.  
  246.   procedure eunote;
  247.   var ax:mstr;
  248.   begin
  249.    buflen30:=true;
  250.    getmstr ('User Note',eurec.note);
  251.    buflen30:=false;
  252.    writeurec;
  253.   end;
  254.  
  255.   procedure boardflags;
  256.   var quit:boolean;
  257.  
  258.     procedure listflags;
  259.     var bd:boardrec;
  260.         cnt:integer;
  261.     begin
  262.       seek (bdfile,0);
  263.       for cnt:=0 to filesize(bdfile)-1 do begin
  264.         read (bdfile,bd);
  265.         tab (bd.shortname,9);
  266.         tab (bd.boardname,30);
  267.         writeln (accessstr[getuseraccflag (eurec,cnt)]);
  268.         if break then exit
  269.       end
  270.     end;
  271.  
  272.     procedure changeflag;
  273.     var bn,q:integer;
  274.         bname:mstr;
  275.         ac:accesstype;
  276.     begin
  277.       buflen:=8;
  278.       writestr ('Board to change access:');
  279.       bname:=input;
  280.       bn:=searchboard(input);
  281.       if bn=-1 then begin
  282.         writeln ('Not found!');
  283.         exit
  284.       end;
  285.       writeln (^B^M'Current access: '^S,
  286.                accessstr[getuseraccflag (eurec,bn)]);
  287.       getacflag (ac,input);
  288.       if ac=invalid then exit;
  289.       setuseraccflag (eurec,bn,ac);
  290.       case ac of
  291.         letin:q:=2;
  292.         keepout:q:=3;
  293.         bylevel:q:=4
  294.       end;
  295.       writelog (18,q,bname)
  296.     end;
  297.  
  298.     procedure allflags;
  299.     var ac:accesstype;
  300.     begin
  301.       writehdr ('Set all board access flags');
  302.       getacflag (ac,input);
  303.       if ac=invalid then exit;
  304.       writestr ('Confirm [Y/N]:');
  305.       if not yes then exit;
  306.       setalluserflags (eurec,ac);
  307.       writelog (18,5,accessstr[ac])
  308.     end;
  309.  
  310.   begin
  311.     opentempbdfile;
  312.     quit:=false;
  313.     repeat
  314.       repeat
  315.         writestr (^M'[L]ist flags, [C]hange one flag, [A]ll flags, or [Q]uit:');
  316.         if hungupon then exit
  317.       until length(input)<>0;
  318.       case upcase(input[1]) of
  319.         'L':listflags;
  320.         'C':changeflag;
  321.         'A':allflags;
  322.         'Q':quit:=true
  323.       end
  324.     until quit;
  325.     closetempbdfile
  326.   end;
  327.  
  328.   procedure specialsysop;
  329.  
  330.     procedure getsysop (c:configtype);
  331.     begin
  332.       writeln ('Section ',sectionnames[c],': '^S,
  333.                sysopstr[c in eurec.config]);
  334.       writestr ('Grant Sysop Access? *');
  335.       if length(input)<>0
  336.         then if yes
  337.           then
  338.             begin
  339.               eurec.config:=eurec.config+[c];
  340.               writelog (18,10,sectionnames[c])
  341.             end
  342.           else
  343.             begin
  344.               eurec.config:=eurec.config-[c];
  345.               writelog (18,11,sectionnames[c])
  346.             end
  347.     end;
  348.  
  349.   begin
  350.     if not truesysop then begin
  351.       truesysops;
  352.       exit
  353.     end;
  354.     writestr
  355. ('Section of [M]ain, [F]ile, [B]ulletin, [V]oting, [E]mail, [D]atabase,'^M+
  356.  '           [O]Doors, [G]-Files, [J]Trivia: *');
  357.     if length(input)=0 then exit;
  358.     case upcase(input[1]) of
  359.       'M':getsysop (mainsysop);
  360.       'F':getsysop (udsysop);
  361.       'B':getsysop (bulletinsysop);
  362.       'V':getsysop (votingsysop);
  363.       'E':getsysop (emailsysop);
  364.       'D':getsysop (databasesysop);
  365.       'O':getsysop (doorssysop);
  366.       'G':getsysop (gfsysop);
  367.       'J':getsysop (jsysop)
  368.     end
  369.   end;
  370.  
  371.   procedure getlogint (prompt:mstr; var i:integer; ln:integer);
  372.   begin
  373.     getint (prompt,i);
  374.     writelog (18,ln,strr(i))
  375.   end;
  376.  
  377.   procedure specialediting;
  378.   begin
  379.    writestr ('Access Code: &');
  380.    if not (match(input,'Z;Z')) then exit;
  381.    writestr ('urec.uploads: *');
  382.    if (length(input)>0) and (valu(input)>-1) then
  383.     eurec.uploads:=valu(input);
  384.    writestr ('urec.downloads: *');
  385.    if (length(input)>0) and (valu(input)>-1) then
  386.     eurec.downloads:=valu(input);
  387.    writestr ('urec.upk=0? *');
  388.    if yes then urec.upk:=0;
  389.    writestr ('urec.downk=0? *');
  390.    if yes then urec.downk:=0;
  391.    writeufile (eurec,eunum);
  392.   end;
  393.  
  394. var q:integer;
  395. begin
  396.   writeurec;
  397.   seek (ufile,eunum);
  398.   read (ufile,eurec);
  399.   writelog (2,3,eurec.handle);
  400.   writeln (^R'Editing User - '+^S+eurec.handle+^R);
  401.   repeat
  402.     q:=menu('User Edit','UEDIT','SDHPLOEWTBQYNIRG!');
  403.     case q of
  404.       1:eustatus;
  405.       2:eudel;
  406.       3:euname;
  407.       4:eupassword;
  408.       5:eulevel;
  409.       6:getlogint ('File Points',eurec.udpoints,7);
  410.       7:getlogint ('File Level',eurec.udlevel,14);
  411.       8:euwanted;
  412.       9:getlogint ('Time left for today',eurec.timetoday,12);
  413.       10:boardflags;
  414.       12:specialsysop;
  415.       13:euphone;
  416.       14:showinfoforms(strr(eunum));
  417.       15:eunote;
  418.       16:eugflevel;
  419.       17:specialediting
  420.     end
  421.   until hungupon or (q=11);
  422.   writeufile (eurec,eunum);
  423.   readurec
  424. end;
  425.  
  426. procedure printnews;
  427. var nfile:file of integer;
  428.     line,nn,x,y,z,tcsrules:integer;
  429.     p:string;
  430. begin
  431.   assign (nfile,'News');
  432.   reset (nfile);
  433.   if ioresult<>0 then exit;
  434.   if filesize (nfile)=0 then begin
  435.     close (nfile);
  436.     exit
  437.   end;
  438.   nn:=0;
  439.   while not (eof(nfile) or break or hungupon) do begin
  440.     read (nfile,line);
  441.     if line>=0 then begin
  442.       writeln;
  443.       nn:=nn+1;
  444.       p:='<Press [CR] to read next News item>*';
  445.       writehdr ('News Item '+strr(nn));
  446.       printtext (line);
  447.       writeln;
  448.     { echoit:=false;
  449.       writestr ('                         <Press [CR] to read next item>*');
  450.       echoit:=true;
  451.       for x:=1 to 25 do write (^H); }
  452.     { z:=urec.displaylen;
  453.       for x:=1 to ((z-length(p)) div 2) do
  454.       begin
  455.        tcsrules:=tcsrules+1;
  456.        write (' ');
  457.       end;
  458.       echoit:=false;
  459.       writestr (p);
  460.       echoit:=true;
  461.       for y:=1 to (length(p)+tcsrules) do
  462.       write (^H); }
  463.     end
  464.   end;
  465.   close (nfile)
  466. end;
  467.  
  468. procedure sendmodemstr (ss:anystr; endifcarrier:boolean);
  469. var cnt,ptr:integer;
  470.     k:char;
  471. label exit;
  472. begin
  473.   ptr:=0;
  474.   while ptr<length(ss) do
  475.     begin
  476.       if keyhit or (carrier=endifcarrier) then goto exit;
  477.       ptr:=ptr+1;
  478.       k:=ss[ptr];
  479.       case k of
  480.         '|':sendchar (^M);
  481.         '~':delay (500);
  482.         '^':begin
  483.               ptr:=ptr+1;
  484.               if ptr>length(ss)
  485.                 then k:='^'
  486.                 else k:=upcase(ss[ptr]);
  487.               if k in ['A'..'Z']
  488.                 then sendchar (chr(ord(k)-64))
  489.                 else sendchar (k)
  490.             end;
  491.         else sendchar (k)
  492.       end;
  493.       delay (50);
  494.       while numchars>0 do writecon (getchar)
  495.     end;
  496.   cnt:=0;
  497.   repeat
  498.     while numchars>0 do begin
  499.       cnt:=0;
  500.       writecon (getchar)
  501.     end;
  502.     cnt:=cnt+1
  503.   until (cnt=1000) or keyhit or (carrier=endifcarrier);
  504.   exit:
  505.   break:=keyhit
  506. end;
  507.  
  508. function getlastcaller:mstr;
  509. var qf:file of lastrec;
  510.     l:lastrec;
  511. begin
  512.   getlastcaller:='';
  513.   assign (qf,'Callers');
  514.   reset (qf);
  515.   if ioresult=0 then
  516.     if filesize(qf)>0
  517.       then
  518.         begin
  519.           seek (qf,0);
  520.           read (qf,l);
  521.           getlastcaller:=l.name
  522.         end;
  523.   close (qf)
  524. end;
  525.  
  526. procedure showlastcallers;
  527. var qf:file of lastrec;
  528.     cnt:integer;
  529.     l:lastrec;
  530. begin
  531.   if ulvl<listuserlvl then exit;
  532.   assign (qf,'Callers');
  533.   reset (qf);
  534.   if ioresult=0 then begin
  535.     writehdr ('Recent Caller List');
  536.     break:=false;
  537.     writeln ('Name                            Date   Time');
  538.     if (asciigraphics in urec.config) then
  539.     writeln ('──────────────────────────────────────────────') else
  540.     writeln ('----------------------------------------------');
  541.     for cnt:=0 to filesize(qf)-1 do
  542.       if not break then begin
  543.         read (qf,l);
  544.         ansicolor (urec.statcolor);
  545.         tab (l.name,31);
  546.         ansicolor (urec.regularcolor);
  547.         writeln (datestr(l.when)+' '+timestr(l.when))
  548.       end
  549.   end;
  550.   close (qf)
  551. end;
  552.  
  553. procedure infoform (i:integer);
  554. var ff:text;
  555.     fn:lstr;
  556.     k:char;
  557.     me:message;
  558. begin
  559.   writeln;
  560.   if (i<1) or (i>5) then exit;
  561.   fn:=textfiledir+'Infoform.'+strr(i);
  562.   if not exist (fn) then begin
  563.     writestr ('There isn''t an Info-Form #'+strr(i)+' right now.');
  564.     if issysop then
  565.       writeln ('Sysop: To make an information form, create a text file',
  566.              ^M'called ',fn,'.  Use * to indicate a pause for user input.');
  567.     exit
  568.   end;
  569.   if i=1 then begin
  570.   if urec.infoform1<>-1 then begin
  571.     writestr ('You have already filled out Information Form #1!  '+^M+
  572.               'Replace it [y/n]? *');
  573.     if not yes then exit;
  574.     deletetext (urec.infoform1);
  575.     urec.infoform1:=-1;
  576.     writeurec
  577.   end;
  578.   end;
  579.   if i=2 then begin
  580.   if urec.infoform2<>-1 then begin
  581.     writestr ('You have an existing information form #2!  '+^M+
  582.               'Replace it [y/n]? *');
  583.     if not yes then exit;
  584.     deletetext (urec.infoform2);
  585.     urec.infoform2:=-1;
  586.     writeurec
  587.   end;
  588.   end;
  589.   if i=3 then begin
  590.   if urec.infoform3<>-1 then begin
  591.     writestr ('You have an existing information form #3!  '+^M+
  592.               'Replace it [y/n]? *');
  593.     if not yes then exit;
  594.     deletetext (urec.infoform3);
  595.     urec.infoform3:=-1;
  596.     writeurec
  597.   end;
  598.   end;
  599.   if i=4 then begin
  600.   if urec.infoform4<>-1 then begin
  601.     writestr ('You have an existing information form #4!  '+^M+
  602.               'Replace it [y/n]? *');
  603.     if not yes then exit;
  604.     deletetext (urec.infoform4);
  605.     urec.infoform4:=-1;
  606.     writeurec
  607.   end;
  608.   end;
  609.   if i=5 then begin
  610.   if urec.infoform5<>-1 then begin
  611.     writestr ('You have an existing information form #5!  '+^M+
  612.               'Replace it [y/n]? *');
  613.     if not yes then exit;
  614.     deletetext (urec.infoform5);
  615.     urec.infoform5:=-1;
  616.     writeurec
  617.   end;
  618.   end;
  619.   assign (ff,fn);
  620.   reset (ff);
  621.   me.numlines:=1;
  622.   me.title:='';
  623.   me.anon:=false;
  624.   me.text[1]:='Filled out on: '+datestr(now)+' at '+timestr(now);
  625.   while not eof(ff) do begin
  626.     if hungupon then begin
  627.       textclose (ff);
  628.       exit
  629.     end;
  630.     read (ff,k);
  631.     if k='*' then begin
  632.       nochain:=true;
  633.       atmenu:=false;
  634.       getstr (1);
  635.       me.numlines:=me.numlines+1;
  636.       me.text[me.numlines]:=input
  637.     end else writechar (k)
  638.   end;
  639.   textclose (ff);
  640.   if i=1 then urec.infoform1:=maketext (me) else
  641.   if i=2 then urec.infoform2:=maketext (me) else
  642.   if i=3 then urec.infoform3:=maketext (me) else
  643.   if i=4 then urec.infoform4:=maketext (me) else
  644.   if i=5 then urec.infoform5:=maketext (me);
  645.   writeurec
  646. end;
  647.  
  648. procedure openusfile;
  649. const newusers:userspecsrec=(name:'New users';minlevel:1;maxlevel:1;
  650.          minlaston:-maxint;maxlaston:maxint;minpcr:-maxint;maxpcr:maxint);
  651. begin
  652.   assign (usfile,'userspec');
  653.   reset (usfile);
  654.   if ioresult<>0 then begin
  655.     rewrite (usfile);
  656.     if level2nd<>0 then newusers.maxlevel:=level2nd;
  657.     write (usfile,newusers)
  658.   end
  659. end;
  660.  
  661. procedure editspecs (var us:userspecsrec);
  662.  
  663.   procedure get (tex:string; var value:integer; min:boolean);
  664.   var vstr:sstr;
  665.   begin
  666.     buflen:=6;
  667.     if abs(value)=maxint then vstr:='None' else vstr:=strr(value);
  668.     writestr (tex+' ['+vstr+']:');
  669.     if input[0]<>#0
  670.       then if upcase(input[1])='N'
  671.         then if min
  672.           then value:=-maxint
  673.           else value:=maxint
  674.         else value:=valu(input)
  675.   end;
  676.  
  677.   procedure getreal (tex:string; var value:real; min:boolean);
  678.   var vstr:sstr;
  679.       s:integer;
  680.   begin
  681.     buflen:=10;
  682.     if abs(value)=maxint then vstr:='None' else vstr:=streal(value);
  683.     writestr (tex+' ['+vstr+']:');
  684.     if length(input)<>0
  685.       then if upcase(input[1])='N'
  686.         then if min
  687.           then value:=-maxint
  688.           else value:=maxint
  689.         else begin
  690.           val (input,value,s);
  691.           if s<>0 then value:=0
  692.         end
  693.   end;
  694.  
  695. begin
  696.   writeln (^B^M'Enter Specifications; N for none.'^M);
  697.   buflen:=30;
  698.   writestr ('Specification set name ['+us.name+']:');
  699.   if length(input)<>0
  700.     then if match(input,'N')
  701.       then us.name:='Unnamed'
  702.       else us.name:=input;
  703.   get ('Lowest level',us.minlevel,true);
  704.   get ('Highest level',us.maxlevel,true);
  705.   get ('Lowest #days since last call',us.minlaston,true);
  706.   get ('Highest #days since last call',us.maxlaston,true);
  707.   getreal ('Lowest post to call ratio',us.minpcr,true);
  708.   getreal ('Highest post to call ratio',us.maxpcr,true)
  709. end;
  710.  
  711. function getspecs (var us:userspecsrec):integer; { -1:not saved   >0:in file }
  712. begin
  713.   with us do begin
  714.     name:='Unnamed';                     { Assumes USFILE is open !! }
  715.     minlevel:=-maxint;
  716.     maxlevel:=maxint;
  717.     minlaston:=-maxint;
  718.     maxlaston:=maxint;
  719.     minpcr:=-maxint;
  720.     maxpcr:=maxint
  721.   end;
  722.   editspecs (us);
  723.   writestr (^M'Save these specs to disk? *');
  724.   if yes then begin
  725.     seek (usfile,filesize(usfile));
  726.     write (usfile,us);
  727.     getspecs:=filesize(usfile)
  728.   end else getspecs:=-1
  729. end;
  730.  
  731. function searchspecs (var us:userspecsrec; name:mstr):integer;
  732. var v,pos:integer;
  733. begin
  734.   v:=valu(name);
  735.   seek (usfile,0);
  736.   pos:=1;
  737.   while not eof(usfile) do begin
  738.     read (usfile,us);
  739.     if match(us.name,name) or (valu(name)=pos) then begin
  740.       searchspecs:=pos;
  741.       exit
  742.     end;
  743.     pos:=pos+1
  744.   end;
  745.   searchspecs:=0;
  746.   writestr (^M'Not found!')
  747. end;
  748.  
  749. procedure listspecs;
  750. var us:userspecsrec;
  751.     pos:integer;
  752.  
  753.   procedure writeval (n:integer);
  754.   begin
  755.     if abs(n)=maxint then write ('   None') else write(n:7)
  756.   end;
  757.  
  758.   procedure writevalreal (n:real);
  759.   begin
  760.     if abs(n)=maxint then write ('   None') else write(n:7:2)
  761.   end;
  762.  
  763. begin
  764.   writehdr ('User Specification Sets');
  765.   seek (usfile,0);
  766.   pos:=0;
  767.   tab ('',35);
  768.   tab ('    Level    ',14);
  769.   tab ('  Last Call  ',14);
  770.   writeln ('  Post/Call Ratio  ');
  771.   while not (break or eof(usfile)) do begin
  772.     pos:=pos+1;
  773.     read (usfile,us);
  774.     write (pos:3,'. ');
  775.     tab (us.name,30);
  776.     writeval (us.minlevel);
  777.     writeval (us.maxlevel);
  778.     writeval (us.minlaston);
  779.     writeval (us.maxlaston);
  780.     writevalreal (us.minpcr);
  781.     writevalreal (us.maxpcr);
  782.     writeln
  783.   end
  784. end;
  785.  
  786. function selectaspec (var us:userspecsrec):integer; {  0 = none         }
  787. var done:boolean;                                   { -1 = not in file  }
  788.     pos:integer;                                    { -2 = added to end }
  789. begin
  790.   selectaspec:=0;
  791.   openusfile;
  792.   if filesize(usfile)=0
  793.     then selectaspec:=getspecs(us)
  794.     else
  795.       repeat
  796.         if hungupon then exit;
  797.         done:=false;
  798.         writestr (^M'Specification Set Name (?/List, A/Add):');
  799.         if length(input)=0
  800.           then done:=true
  801.           else if match(input,'A')
  802.             then
  803.               begin
  804.                 pos:=getspecs(us);
  805.                 if pos>0
  806.                   then selectaspec:=-2
  807.                   else selectaspec:=-1;
  808.                 done:=true
  809.               end
  810.             else if match(input,'?')
  811.               then listspecs
  812.               else
  813.                 begin
  814.                   pos:=searchspecs (us,input);
  815.                   done:=pos<>0;
  816.                   selectaspec:=pos
  817.                 end
  818.       until done;
  819.   close (usfile)
  820. end;
  821.  
  822. function selectspecs (var us:userspecsrec):boolean;
  823. var dummy:integer;
  824. begin
  825.   dummy:=selectaspec (us);
  826.   selectspecs:=dummy=0
  827. end;
  828.  
  829. procedure deletespecs (pos:integer);
  830. var cnt:integer;
  831.     us:userspecsrec;
  832. begin
  833.   openusfile;
  834.   for cnt:=pos to filesize(usfile)-1 do begin
  835.     seek (usfile,cnt);
  836.     read (usfile,us);
  837.     seek (usfile,cnt-1);
  838.     write (usfile,us)
  839.   end;
  840.   seek (usfile,filesize(usfile)-1);
  841.   truncate (usfile);
  842.   close (usfile)
  843. end;
  844.  
  845. procedure editoldspecs;
  846. var pos:integer;
  847.     us:userspecsrec;
  848. begin
  849.   repeat
  850.     pos:=selectaspec (us);
  851.     if pos>0 then begin
  852.       buflen:=1;
  853.       writestr (^M'[E]dit or [D]elete? *');
  854.       if length(input)=1 then case upcase(input[1]) of
  855.         'E':begin
  856.               editspecs (us);
  857.               openusfile;
  858.               seek (usfile,pos-1);
  859.               write (usfile,us);
  860.               close (usfile)
  861.             end;
  862.         'D':deletespecs (pos)
  863.       end
  864.     end
  865.   until (pos=0) or hungupon
  866. end;
  867.  
  868. begin
  869.  buflen30:=false;
  870. end.
  871.