home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C!T ROM 2
/
ctrom_ii_b.zip
/
ctrom_ii_b
/
PROGRAM
/
PASCAL
/
TPKERMIT
/
READCHAR.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1987-03-25
|
3KB
|
52 lines
(* +FILE+ READCHAR.PASMSCPM *)
(* ------------------------------------------------------------------ *)
(* ReadChar - Read a character from the modem. *)
(* Waits for a character to appear on the modem. *)
(* It returns TRUE when the character is received and *)
(* the value of the char is return in the parameter. *)
(* It returns FALSE if the keyboard char is detected before *)
(* a character is received or it times out. *)
(* Side Effects : if the keys ^Z ^X ^C or ^E are pressed then *)
(* BREAKSTATE is set to BZ, BX, BC, or BE respectively. *)
(* Note : The ticker value may need to change if code is added to *)
(* to this procedure or RecvChar or KeyChar. It is also *)
(* machine dependent. *)
(* ------------------------------------------------------------------ *)
Function ReadChar(var char : byte): boolean;
var waiting : boolean ;
dummy : byte ;
Ticker,Timer : integer ;
Begin (* Read Char *)
waiting := true ;
timer := 0 ;
ticker := 0 ;
While waiting Do
Begin (* Wait for a Character *)
If RecvChar(char) then
Begin (* got char *)
ReadChar := true ;
waiting := false ;
End (* got char *)
else
If KeyChar(char,dummy) then
Begin (* key char *)
ReadChar := false ;
waiting := false ;
if char = $03 then BREAKSTATE := BC ;
if char = $05 then BREAKSTATE := BE ;
if char = $18 then BREAKSTATE := BX ;
if char = $1A then BREAKSTATE := BZ ;
End (* key char *)
else
Begin (* Check for timeout *)
if Timer < Timeout then (* increment timer *)
If ticker = 1072 then
Begin ticker := 0 ; Timer := Timer + 1; end
else ticker := ticker + 1
else (* times up *)
Begin Waiting := false; ReadChar := False; End;
End; (* Check for timeout *)
End ; (* Wait for a Character *)
End; (* Read Char *)