home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / simtel / sigm / vols000 / vol072 / terminal.pas < prev    next >
Pascal/Delphi Source File  |  1984-04-29  |  4KB  |  192 lines

  1. { Donated by Warren Smith, Feb 1982 }
  2.  
  3. Program Terminal;
  4.  
  5. Var
  6.     Modem_Mode : byte;    { must be used to hold modem's mode }
  7.     I    : integer;
  8.     Number    : string;
  9.     Xoff    : boolean;
  10.     ESC_Char,
  11.     Answer    : char;
  12.  
  13. { ** Found in CRT.PAS ** }
  14. External Procedure ScreenClr;
  15.  
  16. External Function ConIn : char;
  17.  
  18. External Procedure ConOut (Out_Char : char);
  19.  
  20. External Function KeyPressed : boolean;
  21.  
  22. External Function Get_Console : char;
  23.  
  24. External Procedure GotoXY (X, Y : integer);
  25.  
  26. { ** Found in UTILITY.PAS ** }
  27. External Function Upper (In_Char : char) : char;
  28.  
  29. { ** Found in either DCMODEM.PAS or ACOUSTIC.PAS ** }
  30. External Procedure Init_Modem;
  31.  
  32. External Procedure Set_Modem (Modebyte : byte);
  33.  
  34. External Procedure Go_Onhook (Var Modem_Mode : byte);
  35.  
  36. External Procedure Go_Offhook (Var Modem_Mode : byte);
  37.  
  38. External Procedure Set_Ans_Mode (Var Modem_Mode : byte);
  39.  
  40. External Procedure Set_Org_Mode (Var Modem_Mode : byte);
  41.  
  42. External Procedure Set_110bps (Var Modem_Mode : byte);
  43.  
  44. External Procedure Set_300bps (Var Modem_Mode : byte);
  45.  
  46. External Procedure Enable_Xmit (Var Modem_Mode : byte);
  47.  
  48. External Procedure Disable_Xmit (Var Modem_Mode : byte);
  49.  
  50. External Function Carrier_Present : boolean;
  51.  
  52. External Function Ringing : boolean;
  53.  
  54. External Function Modem_Char_Rdy : boolean;
  55.  
  56. External Function Modem_In : char;
  57.  
  58. External Function Modem_Out (OutChar : char) : boolean;
  59.  
  60. External Procedure Delay;    { delay's for 10 millisecond }
  61.  
  62. External Procedure Dial_a_Number (Var Modem_Mode : byte; Number : string);
  63.  
  64. Procedure Dumb;
  65.  
  66.   Var
  67.     Terminator, In_Char, In_Mod,
  68.     Control_Char, Dummy_Char    : char;
  69.     Half_Duplex, Dummy_Boolean,
  70.     Test_Line            : boolean;
  71.  
  72.   begin { Dumb }
  73.   In_Char := chr(0);
  74.   Terminator := chr(26);
  75.  
  76.   Half_Duplex := TRUE;
  77.   Test_Line := FALSE;
  78.  
  79.   While In_Char <> Terminator do
  80.     begin
  81.     If KeyPressed then
  82.       begin
  83.       In_Char := ConIn;
  84.       If In_Char = chr(13) then    { carriage return }
  85.     In_Char := chr(19);    { control-S used by X-off protocols  }
  86.       If In_Char = ESC_char then
  87.     begin
  88.     Control_Char := Get_Console;
  89.     Dummy_Char := Get_Console;
  90.     Case Control_Char of
  91.       'A' : begin    { Toggle between Full and Half Duplex    }
  92.         Half_Duplex := not Half_Duplex;
  93.         If Half_Duplex then
  94.           Writeln ('Half_Duplex')
  95.         else
  96.           Writeln ('Full Duplex')
  97.         end;
  98.       'B' : In_Char := Terminator;    { Terminates session }
  99.       'C' : Test_Line := not Test_Line;    { Causes display of control }
  100.                         { characters coming in on   }
  101.                         { the modem.            }
  102.       else
  103.       end
  104.     end
  105.       else
  106.     If Modem_Out (In_Char) then
  107.       begin
  108.       If Half_Duplex then
  109.         ConOut (In_Char)
  110.       end
  111.     else
  112.       begin
  113.       Writeln ('Carrier Lost');
  114.       In_Char := Terminator
  115.       end
  116.       end;
  117.  
  118.     If Modem_Char_Rdy then
  119.       begin
  120.       In_Mod := Modem_In;
  121.       If Test_Line then
  122.     If (In_Mod >= ' ') AND (In_Mod <= '~') then
  123.       ConOut (In_Mod)
  124.     else
  125.       begin
  126.       WriteHex (Output, In_Mod, 1);    { This routine outputs in hex }
  127.       Writeln
  128.       end
  129.       else
  130.     ConOut (In_Mod)
  131.       end;
  132.  
  133.     If not Carrier_Present then
  134.       begin
  135.       Writeln ('Carrier Lost');
  136.       In_Char := Terminator
  137.       end
  138.     end
  139.   end;  { Dumb }
  140.  
  141. begin { Main }
  142.  
  143. ESC_Char := chr(01);    { Used by escape sequences, you may want to    }
  144.             { change it to the ASCII ESC character        }
  145.  
  146. ScreenClr;
  147.  
  148. Write('Will you be using X-Off (carriage return = cntl-S) (Y or N)? ');
  149. Read (Answer);
  150. Writeln;
  151. Xoff := Upper(Answer)='Y';
  152.  
  153. Modem_Mode := 0;
  154.  
  155. Init_Modem;
  156.  
  157. Write ('Number Please - ');
  158. Readln (Number);
  159.  
  160. Writeln ('Dialing');
  161.  
  162. Dial_a_Number (Modem_Mode, Number);
  163.  
  164. Set_300bps (Modem_Mode);
  165.  
  166. Set_Org_Mode (Modem_Mode);
  167.  
  168. Enable_Xmit (Modem_Mode);
  169.  
  170. I := 0;        { Set up for 20 second timeout }
  171. While (I < 2000) AND (not Carrier_Present) do
  172.   begin
  173.   Delay;
  174.   I := I + 1
  175.   end;
  176.  
  177. If Carrier_Present then
  178.   begin
  179.   Writeln ('Connection made');
  180.   Dumb
  181.   end
  182. else
  183.   Writeln ('No carrier found, check number - ', Number);
  184.  
  185. Go_Onhook (Modem_Mode);
  186.  
  187. Writeln ('Hanging Up');
  188.  
  189. Writeln ('Program terminated')
  190.  
  191. end.
  192.