home *** CD-ROM | disk | FTP | other *** search
/ Jason Aller Floppy Collection / 270.img / FORUM25C.ZIP / MAINR2.PAS < prev    next >
Pascal/Delphi Source File  |  1989-02-02  |  5KB  |  218 lines

  1. {$R-,S-,I-,D-,V-,B-,N-,L- }
  2. {$O+}
  3.  
  4. unit mainr2;
  5.  
  6.  
  7. {/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\}
  8.  
  9. interface
  10.  
  11. uses gentypes,
  12.      modem,
  13.      subs1,
  14.      subs2,
  15.      statret,
  16.      configrt,
  17.      overret1,
  18.      textret,
  19.      userret,
  20.      mailret,
  21.      lineedit,
  22.      ansiedit,
  23.      mainr1;
  24.  
  25. {/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\}
  26.  
  27.  
  28. Function reedit (VAR m:message; g:boolean):boolean;
  29. Function editor (VAR m:message; gettitle:boolean):integer;
  30. Procedure seekbdfile (n:integer);
  31. Procedure writebdfile (VAR bd:boardrec);
  32. Procedure writecurboard;
  33. Procedure addnews;
  34. Procedure sendmailto (uname:INTEGER; anon:boolean);
  35. Procedure addfeedback (VAR m:mailrec);
  36. Procedure hangupmodem;
  37. Procedure setupmodem;
  38. Procedure dialnumber (num:lstr);
  39. Procedure disconnect;
  40.  
  41.  
  42. {/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\}
  43.  
  44. implementation
  45.  
  46. {/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\}
  47.  
  48.  
  49. Function reedit (VAR m:message; g:boolean):boolean;
  50. Begin
  51.   if fseditor in urec.config then
  52.     Reedit := ansireedit (m,g)
  53.   ELSE
  54.     Reedit := linereedit (m,g);
  55.   trimmessage (m)
  56. end;
  57.  
  58. Function editor (VAR m:message; gettitle:boolean):integer;
  59.  
  60.   Function getthetitle:boolean;
  61.   begin
  62.     m.anon:=false;
  63.     getthetitle:=true;
  64.     if gettitle then begin
  65.       buflen:=30;
  66.       writestr (^M^M'Title: &');
  67.       if length(input)=0 then begin
  68.         getthetitle:=false;
  69.         exit
  70.       end;
  71.       m.title:=input;
  72.       if ulvl>=anonymouslevel then begin
  73.         buflen:=1;
  74.         writestr ('Anonymous? *');
  75.         m.anon:=yes
  76.       end
  77.     end;
  78.   end;
  79.  
  80. Begin
  81.   editor:=-1;
  82.   m.numlines:=0;
  83.   if getthetitle
  84.     then if reedit(m,gettitle)
  85.       then editor:=maketext(m)
  86. end;
  87.  
  88. Procedure seekbdfile (n:integer);
  89. begin
  90.   seek (bdfile,n);
  91.   seek (bifile,n); che
  92. end;
  93.  
  94. Procedure writebdfile (VAR bd:boardrec);
  95. begin
  96.   write (bdfile,bd);
  97.   write (bifile,bd.shortname)
  98. end;
  99.  
  100. Procedure writecurboard;
  101. begin
  102.   seekbdfile (curboardnum);
  103.   writebdfile (curboard); che
  104. end;
  105.  
  106. Procedure addnews;
  107. VAR newline,r:integer;
  108.     nfile:file of integer;
  109.     numnews,cnt:integer;
  110.     m:message;
  111. begin
  112.   writehdr ('Adding to the news');
  113.   newline:=editor (m,false);
  114.   if newline<0 then exit;
  115.   r:=ioresult;
  116.   assign (nfile,'News');
  117.   reset (nfile);
  118.   r:=ioresult;
  119.   if r<>0
  120.     then
  121.       begin
  122.         if r<>1 then writeln ('Error ',r,' opening news file; recreating.');
  123.         rewrite (nfile);
  124.         write (nfile,newline);
  125.         numnews:=0
  126.       end
  127.     else
  128.       begin
  129.         numnews:=filesize(nfile);
  130.         for cnt:=numnews-1 downto 0 do
  131.           begin
  132.             seek (nfile,cnt);
  133.             read (nfile,r);
  134.             seek (nfile,cnt+1);
  135.             write (nfile,r)
  136.           end;
  137.         che;
  138.         seek (nfile,0);
  139.         write (nfile,newline)
  140.       end;
  141.   writeln ('News added.  News items: ',numnews+1);
  142.   writelog (2,1,'');
  143.   close (nfile)
  144. end;
  145.  
  146. Procedure sendmailto (uname : INTEGER; anon : boolean);
  147. VAR un:integer;
  148.     me:message;
  149.     line:integer;
  150.     u:userrec;
  151. begin
  152.   if uname = 0 then exit;
  153.   un := uname;
  154.   if un = 0 then writeln ('User not found.') else begin
  155. {    if anon and (ulvl<sysoplevel) then uname := anonymousstr;   }
  156.     seek (ufile,un);
  157.     read (ufile,u);
  158.     if u.emailannounce>-1 then begin
  159.       writehdr (u.handle+'''s Announcement');
  160.       printtext (u.emailannounce)
  161.     end;
  162.     writehdr ('Sending mail to '+ LookUpUname(uname));
  163.     line := editor(me,true);
  164.     if line >=0 then addmail(un,line,me)
  165.   end
  166. end;
  167.  
  168. Procedure addfeedback (VAR m:mailrec);
  169. VAR ffile:file of mailrec;
  170. begin
  171.   assign (ffile,'Feedback');
  172.   reset (ffile);
  173.   if ioresult<>0 then begin
  174.     close (ffile);
  175.     rewrite (ffile)
  176.   end;
  177.   seek (ffile,filesize(ffile));
  178.   write (ffile,m);
  179.   close (ffile);
  180.   newfeedback:=newfeedback+1;
  181. end;
  182.  
  183. Procedure hangupmodem;
  184. VAR tries:integer;
  185. begin
  186.   tries:=0;
  187.   while carrier and (tries<5) do begin
  188.     hangup;
  189.     sendmodemstr (modemhangupstr,false);
  190.     tries:=tries+1
  191.   end;
  192.   setparam (usecom,baudrate,parity)
  193. end;
  194.  
  195. Procedure setupmodem;
  196. begin
  197.   if carrier then exit;
  198.   writeln (usr,^M^J'Setting up the modem...'^M^J^J);
  199.   sendmodemstr (modemsetupstr,true)
  200. end;
  201.  
  202. Procedure dialnumber (num:lstr);
  203. begin
  204.   sendmodemstr (modemdialprefix+num+modemdialsuffix,true)
  205. end;
  206.  
  207. Procedure disconnect;
  208. begin
  209.   if online then hangupmodem;
  210.   online:=true;
  211.   writelog (0,3,'');
  212.   if (unum>0) and not disconnected then updateuserstats (true);
  213.   disconnected:=true
  214. end;
  215.  
  216. Begin
  217. end.
  218.