home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / CPM / TURBOPAS / PMODEM.ARK / TERMINAL.INC < prev   
Text File  |  1987-02-22  |  5KB  |  164 lines

  1.  
  2. {********** terminal.inc **********}
  3.           { terminal mode }
  4.  
  5. procedure terminal_mode;
  6. var
  7.   local, local1, local2: char;
  8.   temp,command,printer: boolean;
  9. const
  10.   func : data = 'Phillip;Hansford';
  11.  
  12. procedure do_filter(var ch: char);
  13. {Convert cntl code to null --
  14. all control codes except Bell, Line Feed,
  15. and Carriage Return are converted to null}
  16. begin
  17.   if ch in [^A..^_, chr($7F)] then
  18.     if ch in [chr($07)..LF, CR] then else
  19.       ch:= ^@;
  20. end;  {do_filter}
  21.  
  22. procedure logon;
  23. label unclog;
  24. var
  25.   local,local1: char;
  26.   temp: dataa;
  27.   log: array[1..20] of string[40];
  28.   J,numbr,segment: integer;
  29.   toot: boolean;
  30. begin
  31.  if autolog and log_on then begin
  32.   writeln('++ auto logon ++');
  33.   writeln('====================');
  34.   writeln('-->^X to quit');
  35.   segment:= 1;
  36.   numbr:= extractCount(logline);
  37.   for J:= 1 to numbr do log[J]:= extract(logline,J);
  38.   modem_out_line('');
  39.  
  40.   repeat
  41.     sinp(local); if local = ^X then goto unclog;
  42.     local1:= modem_in;
  43.  
  44.      sinp(local); if local = ^X then goto unclog;
  45.      if filter then do_filter(local1);
  46.      write(local1);
  47.      if printer then write(Lst,local1);
  48.  
  49.     sinp(local); if local = ^X then goto unclog;
  50.     temp:= log[segment];
  51.     if temp= '$' then temp:= ^G;
  52.     if temp= '^' then begin
  53.       delay(500);
  54.       modem_out(^C);
  55.     end;
  56.     if temp= '#' then begin
  57.       delay(4000);
  58.       modem_out(CR);
  59.       sinp(local); if local = ^X then goto unclog;
  60.       delay(500);
  61.       sinp(local); if local = ^X then goto unclog;
  62.       modem_out(CR);
  63.       sinp(local); if local = ^X then goto unclog;
  64.       delay(500);
  65.       modem_out(CR);
  66.       sinp(local); if local = ^X then goto unclog;
  67.       delay(500);
  68.       modem_out(CR);
  69.       sinp(local); if local = ^X then goto unclog;
  70.       delay(500);
  71.       temp:= '';
  72.     end;
  73.     sinp(local); if local = ^X then goto unclog;
  74.     if (local1 = temp) or (temp = '')
  75.      then begin
  76.      sinp(local); if local = ^X then goto unclog;
  77.      segment:= segment+ 1;
  78.        temp:= log[segment];
  79.         if temp = ',' then begin
  80.          delay(2000);
  81.          modem_out_line('');
  82.          sinp(local); if local = ^X then goto unclog;
  83.        end
  84.        else
  85.          delay(100);
  86.          if (not hiBaud) or slowbaud then delay(400);
  87.          modem_out_line(temp);
  88.          sinp(local); if local = ^X then goto unclog;
  89.          segment:= segment+ 1;
  90.      end;
  91.  
  92.      sinp(local); if local = ^X then goto unclog;
  93.   until segment >= numbr;
  94. unclog:
  95.   writeln;
  96.   writeln('=(',segment,')================');
  97.   autolog:= false;
  98.  end;
  99. end; {logon}
  100.  
  101. begin  {terminal_mode}
  102.   printer:= false;
  103.   if not host_mode then begin
  104.     write('TERMINAL MODE (');
  105.     if carrier then writeln('carrier)') else writeln('no carrier)');
  106.     writeln('(^P - printer, ^E - menu)');
  107.   end;
  108.   writeln;
  109.   if carrier and not host_mode then logon;
  110.   if (not carrier) and duplex then command:= true
  111.     else command:= false;
  112.   line:= '';
  113.   repeat
  114.   sinp(local);
  115.   if local <> ^@ then begin  {^@ is 0 = no char}
  116.     if local in [^E, ^P, ESC] then else begin;
  117.         if command then local:= upCase(local);
  118.         modem_out(local);
  119.         if not duplex then write(local);     {half-duplex}
  120.         if command then begin
  121.           line:= line + local;
  122.           write(local);
  123.         end;
  124.     end;
  125.     case local of
  126.       ^M: begin  {ie. CR}
  127.             {modem_out(LF);}
  128.             if not duplex then begin
  129.                modem_out(LF);
  130.                write(LF);
  131.             end;
  132.             if command then write(LF);
  133.           end;
  134.       ^P: printer:= not printer;
  135.       ^@: begin
  136.             writeln('Break noted');
  137.             delay(100);
  138.           end;
  139.       ^[: begin
  140.              delay(10); {check for function key}
  141.              sinp(local2);
  142.              if local2 = 'S' then begin  {function 1 key}
  143.                modem_out_line(func);
  144.                if not duplex then writeln(log_on);
  145.              end
  146.              else if local2 = ^@ then begin  {not function key}
  147.                modem_out(local);
  148.                if not duplex then write(local);
  149.              end;
  150.           end;
  151.     end;
  152.   end;
  153.   if Modem_In_Ready then begin
  154.     local1:= getMod;
  155.     if filter then do_filter(local1);
  156.     write(local1);
  157.     if not duplex then modem_out(local1);
  158.     if printer then write(Lst,local1);
  159.   end;
  160.   until local= ^E;
  161.   modem_out(^@);  {any chr to hang up if dialing}
  162. end; {terminal_mode}
  163.  
  164.