home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
GEMini Atari
/
GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso
/
files
/
bbs
/
pibterm
/
pibt3sp3
/
receivea.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1985-09-11
|
6KB
|
159 lines
(*----------------------------------------------------------------------*)
(* Receive_Ascii_File --- Download ASCII file *)
(*----------------------------------------------------------------------*)
OVERLAY PROCEDURE Receive_Ascii_File;
(*----------------------------------------------------------------------*)
(* *)
(* Procedure: Receive_Ascii_File *)
(* *)
(* Purpose: Downloads ASCII file to PC *)
(* *)
(* Calling Sequence: *)
(* *)
(* Receive_Ascii_File; *)
(* *)
(* Calls: KeyPressed *)
(* Async_Send *)
(* Async_Receive *)
(* Async_Percentage_Used *)
(* *)
(* Remarks: *)
(* *)
(* XON/XOFF is assumed to be supported by the host. *)
(* *)
(*----------------------------------------------------------------------*)
VAR
Ch : CHAR;
Fin : BOOLEAN;
XOFF_Sent : BOOLEAN (* TRUE if XOFF sent to host *);
X : INTEGER;
Y : INTEGER;
N_Xoff : INTEGER;
Line_Count : REAL;
Byte_Count : REAL;
(*----------------------------------------------------------------------*)
(* Update_Ascii_Receive_Display --- Update display of Xmodem reception *)
(*----------------------------------------------------------------------*)
PROCEDURE Update_Ascii_Receive_Display;
BEGIN (* Update_Ascii_Receive_Display *)
GoToXY( 17 , 1 );
WRITE( Line_Count:8:0 );
GoToXY( 17 , 2 );
WRITE( Byte_Count:8:0 );
END (* Update_Ascii_Receive_Display *);
(*----------------------------------------------------------------------*)
BEGIN (* Receive_Ascii_File *)
Fin := FALSE;
XOFF_Sent := FALSE;
N_Xoff := 0;
Line_Count := 0;
Byte_Count := 0;
(* Open display window for transfer *)
Save_Screen( Saved_Screen );
Draw_Menu_Frame( 15, 10, 78, 17, Menu_Frame_Color,
Menu_Text_Color,
'Receive file ' + FileName + ' using ASCII' );
(* Headings for status information *)
Window( 16, 11, 77, 16 );
WRITELN(' Lines received: ');
WRITELN(' Bytes received: ');
WRITELN(' ');
(* Open reception file *)
ASSIGN( Afile, FileName );
REWRITE( AFile );
REPEAT
IF Async_Percentage_Used > 0.75 THEN
BEGIN (* Buffer too full -- send XOFF if we already haven't *)
IF ( NOT XOFF_Sent ) THEN
BEGIN
Async_Send( CHR( XOFF ) );
XOFF_Sent := TRUE;
GoToXY( 1 , 4 );
WRITE(' XOFF sent, percentage = ',Async_Percentage_Used:5:2 );
ClrEol;
N_Xoff := N_Xoff + 1;
END
END (* Buffer too full *)
ELSE IF Async_Percentage_Used < 0.25 THEN
BEGIN (* Buffer reasonably empty -- send XON if needed *)
IF XOFF_Sent THEN
BEGIN
Async_Send( CHR( XON ) );
XOFF_Sent := FALSE;
GoToXY( 1 , 4 );
WRITE(' XON sent, percentage = ',Async_Percentage_Used:5:2 );
ClrEol;
END;
END;
(* Check for Alt_R -- ends transfer *)
IF KeyPressed THEN
BEGIN
READ( Kbd , Ch );
IF ( Ch = CHR( ESC ) ) AND KeyPressed THEN
BEGIN
READ( Kbd , Ch );
IF ORD( Ch ) = Alt_R THEN
Fin := TRUE;
END
ELSE
Async_Send( Ch );
END;
IF Async_Receive( Ch ) THEN
BEGIN
WRITE( AFile , Ch );
Byte_Count := Byte_Count + 1;
IF ( Ch = CHR( CR ) ) THEN
BEGIN
Line_Count := Line_Count + 1;
Update_Ascii_Receive_Display;
END;
END;
Fin := Fin OR Async_Carrier_Drop;
UNTIL ( Fin );
IF Async_Carrier_Drop THEN
BEGIN
GoToXY( 1 , 4 );
Writelne('Carrier dropped, transfer stopped.' , TRUE );
END
ELSE
BEGIN
GoToXY( 1 , 4 );
Writelne('Finished receiving ASCII file ' + FileName , TRUE );
GoToXY( 1 , 5 );
WRITELN('Number of XOFFs sent: ',N_Xoff);
END;
DELAY( Two_Second_Delay );
CLOSE( AFile );
(* Remove this window *)
Restore_Screen( Saved_Screen );
Reset_Global_Colors;
END (* Receive_Ascii_File *);
ə