home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / PIBTERM / PIBT41S4.ARC / SENDASCI.MOD < prev    next >
Encoding:
Text File  |  1988-03-23  |  23.9 KB  |  748 lines

  1. (*----------------------------------------------------------------------*)
  2. (*                Send_Ascii_File --- Upload ASCII file                 *)
  3. (*----------------------------------------------------------------------*)
  4.  
  5. PROCEDURE Send_Ascii_File;
  6.  
  7. (*----------------------------------------------------------------------*)
  8. (*                                                                      *)
  9. (*     Procedure:  Send_Ascii_File                                      *)
  10. (*                                                                      *)
  11. (*     Purpose:    Uploads ASCII file to remote host                    *)
  12. (*                                                                      *)
  13. (*     Calling Sequence:                                                *)
  14. (*                                                                      *)
  15. (*        Send_Ascii_File;                                              *)
  16. (*                                                                      *)
  17. (*     Calls:   PibTerm_KeyPressed                                      *)
  18. (*              Send_String_With_Delays_And_Echo                        *)
  19. (*              Async_Receive                                           *)
  20. (*                                                                      *)
  21. (*----------------------------------------------------------------------*)
  22.  
  23. CONST
  24.    Pacing_Delay  = 0.10            (* Approx. time added per line for pacing *);
  25.    Modem_Fudge   = 0.85            (* Approx. fudge factor for timing        *);
  26.    Max_Wait_Time = 60              (* Maximum wait time for output drain     *);
  27.  
  28. VAR
  29.    Ch           : CHAR;
  30.    A_Ch         : CHAR;
  31.    Fin          : BOOLEAN;
  32.    TextLine     : AnyStr;
  33.    Esc_Found    : BOOLEAN;
  34.    B            : BOOLEAN;
  35.    Pace_Found   : BOOLEAN;
  36.    Line_Count   : LONGINT;
  37.    Line_Kount   : LONGINT;
  38.    Byte_Count   : LONGINT;
  39.    Time_To_Send : LONGINT;
  40.    Length_Line  : LONGINT;
  41.    R_Baud_Rate  : REAL;
  42.    Start_Time   : LONGINT;
  43.    Pacing       : BOOLEAN;
  44.    Pace_Time    : BOOLEAN;
  45.    I            : INTEGER;
  46.    X            : INTEGER;
  47.    Y            : INTEGER;
  48.    Ascii_Display: BOOLEAN;
  49.    EOF_AFile    : BOOLEAN;
  50.    Do_Send_Blank: BOOLEAN;
  51.    CR_LF_String : ShortStr;
  52.    SBSize       : STRING[20];
  53.    SLSize       : STRING[20];
  54.  
  55.                                    (* Read buffer pointer               *)
  56.  
  57.    Read_Buffer  : File_Handle_Buffer_Ptr;
  58.  
  59.    Buffer_Pos   : INTEGER          (* Current buffer position           *);
  60.    Buffer_Length: INTEGER          (* Buffer length                     *);
  61.    Buffer_Size  : INTEGER          (* Buffer size as read               *);
  62.    AFile        : FILE             (* File for read                     *);
  63.    Max_DLine    : INTEGER          (* Maximum display line for transfer *);
  64.    Long_Buffer  : BOOLEAN          (* TRUE if long buffer being used    *);
  65.    R_Char_Delay : REAL             (* Character delay in seconds        *);
  66.    R_Line_Delay : REAL             (* Line delay in seconds             *);
  67.    Ascii_Title  : AnyStr           (* Title for transfer                *);
  68.    Alt_S_Hit    : BOOLEAN          (* TRUE if Alt-S hit.                *);
  69.    T1           : LONGINT          (* Starting time for end-of-send     *);
  70.  
  71. LABEL 1;
  72.  
  73. (*----------------------------------------------------------------------*)
  74. (*     Initialize_Send_Window --- initialize send status window area    *)
  75. (*----------------------------------------------------------------------*)
  76.  
  77. PROCEDURE Initialize_Send_Window;
  78.  
  79. BEGIN (* Initialize_Send_Window *)
  80.  
  81.    Save_Screen( Saved_Screen );
  82.  
  83.    Draw_Menu_Frame( 15, 3, 78, 14, Menu_Frame_Color, Menu_Title_Color,
  84.                     Menu_Text_Color, Ascii_Title );
  85.  
  86.    PibTerm_Window( 16, 4, 77, 13 );
  87.  
  88. END   (* Initialize_Send_Window *);
  89.  
  90. (*----------------------------------------------------------------------*)
  91. (*   Initialize_Status_Display --- initialize transfer status display   *)
  92. (*----------------------------------------------------------------------*)
  93.  
  94. PROCEDURE Initialize_Status_Display;
  95.  
  96. VAR
  97.    I: INTEGER;
  98.  
  99. BEGIN (* Initialize_Status_Display *)
  100.  
  101.                                    (* Figure last line in display *)
  102.    IF ( NOT Do_Status_Line ) THEN
  103.       Max_DLine := Max_Screen_Line
  104.    ELSE
  105.       Max_DLine := PRED( Max_Screen_Line );
  106.  
  107.                                    (* Transfer statistics  *)
  108.  
  109.    TextColor( Menu_Text_Color_2 );
  110.    WRITE  (' Characters to send    : ');
  111.    TextColor( Menu_Text_Color );
  112.    WRITELN( Byte_Count:8 );
  113.    TextColor( Menu_Text_Color_2 );
  114.    WRITE  (' Lines to send         : ');
  115.    TextColor( Menu_Text_Color );
  116.    WRITELN( Line_Count:8 );
  117.    TextColor( Menu_Text_Color_2 );
  118.    WRITE  (' Approx. transfer time : ');
  119.    TextColor( Menu_Text_Color );
  120.    WRITELN( TimeString( Time_To_Send , Military_Time ) );
  121.    WRITELN(' ');
  122.    TextColor( Menu_Text_Color_2 );
  123.    WRITELN(' Sending line          : ');
  124.    WRITELN(' Bytes left to send    : ');
  125.    WRITE  (' Approx. time left     : ');
  126.    TextColor( Menu_Text_Color );
  127.    WRITELN( TimeString( Time_To_Send , Military_Time ) );
  128.  
  129.                                    (* Open display window for received *)
  130.                                    (* text lines.                      *)
  131.    IF Ascii_Display THEN
  132.       BEGIN
  133.  
  134.          PibTerm_Window( 1, 1, Max_Screen_Col, Max_DLine );
  135.          GoToXY( 1 , 15 );
  136.  
  137.          TextColor( Menu_Text_Color );
  138.  
  139.          FOR I := 1 TO 24 DO WRITE('=');
  140.  
  141.          TextColor( Menu_Text_Color_2 );
  142.  
  143.          WRITE('Output from remote system below');
  144.  
  145.          TextColor( Menu_Text_Color );
  146.  
  147.          FOR I := 1 TO 25 DO WRITE('=');
  148.  
  149.          PibTerm_Window( 1, 16, Max_Screen_Col, Max_DLine );
  150.          GoToXY( 1 , 1 );
  151.          Clear_Window;
  152.  
  153.       END;
  154.  
  155. END   (* Initialize_Status_Display *);
  156.  
  157. (*----------------------------------------------------------------------*)
  158. (*        Flip_Display_Status --- turn status display on/off            *)
  159. (*----------------------------------------------------------------------*)
  160.  
  161. PROCEDURE Flip_Display_Status;
  162.  
  163. BEGIN (* Flip_Display_Status *)
  164.  
  165.    CASE Display_Status OF
  166.  
  167.       TRUE:   BEGIN
  168.                                    (* Indicate no display   *)
  169.  
  170.                  Display_Status := FALSE;
  171.  
  172.                                    (* Remove XMODEM window  *)
  173.  
  174.                  Restore_Screen_And_Colors( Saved_Screen );
  175.  
  176.               END;
  177.  
  178.       FALSE:  BEGIN
  179.                                    (* Indicate display will be done *)
  180.  
  181.                  Display_Status := TRUE;
  182.                  Ascii_Display  := Ascii_Show_Text;
  183.  
  184.                                    (* Save screen image *)
  185.  
  186.                  Save_Screen( Saved_Screen );
  187.  
  188.                                    (* Initialize Ascii display window   *)
  189.  
  190.                  Initialize_Send_Window;
  191.                  Initialize_Status_Display;
  192.  
  193.               END;
  194.  
  195.    END (* CASE *);
  196.  
  197. END   (* Flip_Display_Status *);
  198.  
  199. (*----------------------------------------------------------------------*)
  200. (*      Activate_Status_Window --- Activate the display status window   *)
  201. (*----------------------------------------------------------------------*)
  202.  
  203. PROCEDURE Activate_Status_Window;
  204.  
  205. BEGIN (* Activate_Status_Window *)
  206.  
  207.    IF Ascii_Display THEN
  208.       BEGIN
  209.          X := WhereX;
  210.          Y := WhereY;
  211.          PibTerm_Window( 16, 4, 77, 13 );
  212.       END;
  213.  
  214. END   (* Activate_Status_Window *);
  215.  
  216. (*----------------------------------------------------------------------*)
  217. (*         Activate_Text_Window --- switch to text display window       *)
  218. (*----------------------------------------------------------------------*)
  219.  
  220. PROCEDURE Activate_Text_Window;
  221.  
  222. BEGIN (* Activate_Text_Window *)
  223.  
  224.    IF Ascii_Display THEN
  225.       BEGIN
  226.          PibTerm_Window( 1, 16, Max_Screen_Col, Max_DLine );
  227.          GoToXY( X , Y );
  228.       END;
  229.  
  230. END   (* Activate_Text_Window *);
  231.  
  232. (*----------------------------------------------------------------------*)
  233. (*      Ascii_Receive --- Interface to receive character from port      *)
  234. (*----------------------------------------------------------------------*)
  235.  
  236. FUNCTION Ascii_Receive( VAR Ch: CHAR ) : BOOLEAN;
  237.  
  238. VAR
  239.    KeyC: CHAR;
  240.  
  241. BEGIN (* Ascii_Receive *)
  242.  
  243.    IF Async_Receive( Ch ) THEN
  244.       BEGIN
  245.  
  246.          Ascii_Receive := TRUE;
  247.  
  248.          CASE ORD( Ch ) OF
  249.  
  250.             NUL  : Ascii_Receive := FALSE;  (* Strip Nulls   *)
  251.             DEL  : Ascii_Receive := FALSE;  (* Strip Deletes *)
  252.             BELL : Menu_Beep;
  253.             ELSE
  254.                    IF Ascii_Display THEN
  255.                       WRITE( Ch );
  256.  
  257.          END (* CASE *);
  258.       END
  259.    ELSE
  260.       Ascii_Receive := FALSE;
  261.  
  262. END   (* Ascii_Receive *);
  263.  
  264. (*----------------------------------------------------------------------*)
  265. (*      Ascii_Send --- Interface to send character out over serial port *)
  266. (*----------------------------------------------------------------------*)
  267.  
  268. PROCEDURE Ascii_Send( Ch : CHAR );
  269.  
  270. BEGIN (* Ascii_Send *)
  271.  
  272.    IF Ascii_Display THEN
  273.       Async_Send_Now( Ch )
  274.    ELSE
  275.       Async_Send( Ch );
  276.  
  277. END   (* Ascii_Send *);
  278.  
  279. (*----------------------------------------------------------------------*)
  280. (*     Update_Ascii_Send_Display --- Update display of Ascii upload     *)
  281. (*----------------------------------------------------------------------*)
  282.  
  283. PROCEDURE Update_Ascii_Send_Display;
  284.  
  285. BEGIN (* Update_Ascii_Send_Display *)
  286.  
  287.    Activate_Status_Window;
  288.  
  289.    TextColor( Menu_Text_Color );
  290.  
  291.    GoToXY( 26 , 5 );
  292.    WRITE( Line_Count:8 );
  293.    GoToXY( 26 , 6 );
  294.    WRITE( Byte_Count:8 );
  295.    GoToXY( 26 , 7 );
  296.    WRITE( TimeString( Time_To_Send , Military_Time ) );
  297.  
  298.    Activate_Text_Window;
  299.  
  300. END   (* Update_Ascii_Send_Display *);
  301.  
  302. (*----------------------------------------------------------------------*)
  303. (*         Send_Ascii_Line --- send one line of text from file          *)
  304. (*----------------------------------------------------------------------*)
  305.  
  306. PROCEDURE Send_Ascii_Line;
  307.  
  308. VAR
  309.    B: BOOLEAN;
  310.    I: INTEGER;
  311.  
  312. BEGIN (* Send_Ascii_Line *)
  313.  
  314.    FOR I := 1 TO LENGTH( TextLine ) DO
  315.       BEGIN
  316.                                    (* Send a character *)
  317.          Ascii_Send( TextLine[I] );
  318.  
  319.                                    (* Intercharacter delay *)
  320.  
  321.          IF ( Ascii_Char_Delay > 0 ) THEN
  322.             DELAY( Ascii_Char_Delay );
  323.  
  324.                                    (* Print a character from spooled file *)
  325.          IF Print_Spooling THEN
  326.             Print_Spooled_File;
  327.                                    (* Process any received character *)
  328.          B := Ascii_Receive( Ch );
  329.  
  330.       END;
  331.                                    (* Interline delay *)
  332.    IF ( NOT Pacing ) THEN
  333.       BEGIN
  334.  
  335.          IF ( Ascii_Line_Delay > 0 ) THEN
  336.             DELAY( Ascii_Line_Delay );
  337.  
  338.                                    (* Drain the buffer *)
  339.  
  340.          WHILE Ascii_Receive( Ch ) DO;
  341.  
  342.       END;
  343.                                    (* Display text if local echo *)
  344.    TextColor( Menu_Text_Color );
  345.  
  346.    IF Local_Echo THEN
  347.       WRITELN( TextLine );
  348.  
  349. END   (* Send_Ascii_Line *);
  350.  
  351. (*----------------------------------------------------------------------*)
  352.  
  353. PROCEDURE Read_A_Line( VAR S: AnyStr );
  354.  
  355. VAR
  356.    I        : INTEGER;
  357.    Eol      : BOOLEAN;
  358.    Ierr     : INTEGER;
  359.  
  360. BEGIN (* Read_A_Line *)
  361.  
  362.    I           := 0;
  363.    Eol         := FALSE;
  364.    S           := '';
  365.  
  366.    WHILE( NOT ( Eol OR EOF_AFile ) ) DO
  367.       BEGIN
  368.  
  369.          INC( Buffer_Pos );
  370.  
  371.          IF ( Buffer_Pos > Buffer_Size ) THEN
  372.             BEGIN
  373.                                    (* Read Buffer_Length chars from file  *)
  374.                                    (* to be sent.                         *)
  375.  
  376.                BlockRead( AFile, Read_Buffer^, Buffer_Length, Buffer_Size );
  377.  
  378.                Ierr       := Int24Result;
  379.                Buffer_Pos := 1;
  380.                                    (* If no chars. read, then EOF      *)
  381.  
  382.                IF ( ( Buffer_Size <= 0 ) OR ( Ierr <> 0 ) ) THEN
  383.                   BEGIN
  384.                      Eol         := TRUE;
  385.                      EOF_AFile   := TRUE;
  386.                   END;
  387.  
  388.             END;
  389.                                    (* Place char into send string *)
  390.  
  391.          IF ( NOT EOF_AFile ) THEN
  392.             IF ( NOT Ascii_Send_Asis ) THEN
  393.                CASE Read_Buffer^[Buffer_Pos] OF
  394.                   CR:  ;
  395.                   LF:  Eol  := TRUE;
  396.                   ELSE BEGIN
  397.                           INC( I );
  398.                           S[I] := CHR(Read_Buffer^[Buffer_Pos]);
  399.                           Eol  := Eol OR ( I > 252 );
  400.                        END;
  401.                END (* CASE *)
  402.             ELSE
  403.                BEGIN
  404.                   INC( I );
  405.                   S[I] := CHR(Read_Buffer^[Buffer_Pos]);
  406.                   Eol  := Eol OR ( I > Ascii_Line_Size );
  407.                END;
  408.  
  409.       END;
  410.                                    (* Remove trailing Ctrl-Z *)
  411.    IF ( I > 0 ) THEN
  412.       IF ( S[I] = ^Z ) THEN
  413.          DEC( I );
  414.  
  415.    S[0] := CHR( I );
  416.  
  417. END   (* Read_A_Line *);
  418.  
  419. (*----------------------------------------------------------------------*)
  420.  
  421. BEGIN (* Send_Ascii_File *)
  422.                                    (* Disable cursor                    *)
  423.    CursorOff;
  424.                                    (* Open display window for transfer  *)
  425.  
  426.    Ascii_Title := 'Send file ' + FileName + ' using ASCII';
  427.  
  428.    Write_Log( Ascii_Title, FALSE, FALSE );
  429.  
  430.    Initialize_Send_Window;
  431.                                    (* Figure transfer time *)
  432.  
  433.    Byte_Count     := Get_File_Size( FileName , Open_OK );
  434.    R_Baud_Rate    := ( Baud_Rate * Modem_Fudge ) / 10.0;
  435.    Line_Count     := 0;
  436.    Alt_S_Hit      := FALSE;
  437.                                    (* Read file and find # of lines *)
  438.    TextColor( Menu_Text_Color_2 );
  439.    WRITELN;
  440.    WRITE  (' Scanning ');
  441.  
  442.    TextColor( Menu_Text_Color );
  443.    WRITE  ( FileName   );
  444.  
  445.    TextColor( Menu_Text_Color_2 );
  446.    WRITELN(' for file size');
  447.  
  448.                                    (* Allocate buffer if requested   *)
  449.                                    (* otherwise use sector data area *)
  450.                                    (* directly.                      *)
  451.  
  452.    IF ( Max_Write_Buffer > MaxSectorLength ) AND
  453.       ( Max_Write_Buffer < MaxAvail        ) THEN
  454.       BEGIN
  455.          Buffer_Length  := Max_Write_Buffer;
  456.          Long_Buffer    := TRUE;
  457.          GetMem( Read_Buffer , Buffer_Length );
  458.          IF ( Read_Buffer = NIL ) THEN
  459.             BEGIN
  460.                Long_Buffer   := FALSE;
  461.                Buffer_Length := MaxSectorLength;
  462.                Read_Buffer   := ADDR( Sector_Data );
  463.             END;
  464.       END
  465.    ELSE
  466.       BEGIN
  467.          Long_Buffer   := FALSE;
  468.          Buffer_Length := MaxSectorLength;
  469.          Read_Buffer   := ADDR( Sector_Data );
  470.       END;
  471.                                    (* Open file to send *)
  472.    FileMode := 0;
  473.  
  474.    ASSIGN( AFile , FileName );
  475.    RESET ( AFile , 1 );
  476.  
  477.    FileMode := 2;
  478.  
  479.    IF ( Int24Result <> 0 ) THEN
  480.       BEGIN
  481.          Write_Log( 'Cannot open file to send, transfer cancelled.',
  482.                     TRUE, TRUE );
  483.          Window_Delay;
  484.          Restore_Screen_And_Colors( Saved_Screen );
  485.          CursorOn;
  486.          EXIT;
  487.       END;
  488.                                    (* Empty read buffer   *)
  489.  
  490.    Buffer_Pos     := Buffer_Length + 1;
  491.    Buffer_Size    := 0;
  492.    EOF_AFile      := FALSE;
  493.                                    (* Get number of lines in file *)
  494.    REPEAT
  495.       Read_A_Line( TextLine );
  496.       INC( Line_Count );
  497.    UNTIL( EOF_AFile );
  498.  
  499.    CLOSE( AFile );
  500.  
  501.    FileMode := 0;
  502.  
  503.    RESET ( AFile , 1 );
  504.  
  505.    FileMode := 2;
  506.  
  507.    I := Int24Result;
  508.  
  509.    Buffer_Pos  := Buffer_Length + 1;
  510.    Buffer_Size := 0;
  511.    EOF_AFile   := FALSE;
  512.                                    (* Display size in log              *)
  513.  
  514.    STR( Byte_Count , SBSize );
  515.    STR( Line_Count , SLSize );
  516.  
  517.    Write_Log('Size of file to send is ' + SBSize + ' bytes, ' +
  518.              SLSize + ' lines', TRUE, FALSE );
  519.  
  520.                                    (* Figure approximate transfer time *)
  521.  
  522.    R_Char_Delay   := Ascii_Char_Delay / 1000.0;
  523.    R_Line_Delay   := Ascii_Line_Delay / 1000.0;
  524.  
  525.    Time_To_Send   := ROUND( Byte_Count / R_Baud_Rate +
  526.                             R_Char_Delay * Byte_Count +
  527.                             R_Line_Delay * Line_Count );
  528.  
  529.    Pace_Time := ( Ascii_Char_Delay   = 0 ) AND
  530.                 ( Ascii_Line_Delay   = 0 ) AND
  531.                 ( Ascii_Pacing_Char <> CHR( NUL ) ) AND
  532.                 ( Ascii_Pacing_Char <> ' '        );
  533.  
  534.    IF Pace_Time THEN
  535.       Time_To_Send := ROUND( Time_To_Send + Line_Count *
  536.                              ( Pacing_Delay + R_Line_Delay ) );
  537.  
  538.                                    (* Get parameters for Ascii transfer *)
  539.  
  540.    Do_Send_Blank := Ascii_Send_Blank;
  541.    CR_LF_String  := Ascii_CR_LF_String;
  542.  
  543.    IF Ascii_Send_Asis THEN
  544.       BEGIN
  545.          Do_Send_Blank := FALSE;
  546.          CR_LF_String  := '';
  547.       END;
  548.                                    (* FIN is true when upload complete *)
  549.    Fin            := FALSE;
  550.                                    (* Remember starting time           *)
  551.    Start_Time     := TimeOfDay;
  552.                                    (* Flag if pacing char found:       *)
  553.                                    (* assumed TRUE to start things off *)
  554.    Pace_Found     := TRUE;
  555.    Pacing         := FALSE;
  556.                                    (* Assume display to start with     *)
  557.  
  558.    Ascii_Display  := Ascii_Show_Text;
  559.  
  560.                                    (* Initialize status display        *)
  561.    Clear_Window;
  562.    Initialize_Status_Display;
  563.                                    (* Reset line count                 *)
  564.    Line_Kount     := Line_Count;
  565.    Line_Count     := 0;
  566.                                    (* Loop over lines in file          *)
  567.  
  568.    REPEAT
  569.                                    (* Read a line                      *)
  570.          Read_A_Line( TextLine );
  571.                                    (* Don't send bogus last line!      *)
  572.  
  573.          IF ( EOF_AFile AND ( LENGTH( TextLine ) = 0 ) ) THEN GOTO 1;
  574.  
  575.                                    (* Turn empty line into 1 blank if desired *)
  576.  
  577.          IF Do_Send_Blank THEN
  578.            IF ( LENGTH( TextLine ) = 0 ) THEN
  579.                TextLine := ' ';
  580.                                    (* Append cr or cr+lf as needed        *)
  581.  
  582.          TextLine    := TextLine + CR_LF_String;
  583.          Length_Line := LENGTH( TextLine ) + LENGTH( CR_LF_String );
  584.  
  585.                                    (* If pacing character specified, wait *)
  586.                                    (* for it to show up from com port     *)
  587.          Esc_Found  := FALSE;
  588.  
  589.          IF ( Pacing AND ( NOT Fin ) ) THEN
  590.             REPEAT
  591.                IF PibTerm_KeyPressed THEN
  592.                   BEGIN
  593.                      Read_Kbd( Ch );
  594.                      IF Ch = CHR( ESC ) THEN
  595.                         Esc_Found := TRUE
  596.                      ELSE
  597.                         BEGIN
  598.                            B := Ascii_Receive( A_Ch );
  599.                            Ascii_Send( Ch );
  600.                         END;
  601.                   END;
  602.                IF Ascii_Receive( Ch ) THEN
  603.                   BEGIN
  604.                      Pace_Found := ( Ch = Ascii_Pacing_Char );
  605.                      IF Pace_Found THEN
  606.                         DELAY( Ascii_Line_Delay );
  607.                   END;
  608.             UNTIL ( Pace_Found OR Esc_Found )
  609.          ELSE
  610.             REPEAT
  611.                IF PibTerm_KeyPressed THEN
  612.                   BEGIN
  613.                      Read_Kbd( Ch );
  614.                      IF Ch = CHR( ESC ) THEN
  615.                         Esc_Found := TRUE
  616.                      ELSE
  617.                         BEGIN
  618.                            B := Ascii_Receive( A_Ch );
  619.                            Ascii_Send( Ch );
  620.                         END;
  621.                   END;
  622.                B := Ascii_Receive( Ch );
  623.             UNTIL ( Pace_Found OR Esc_Found );
  624.  
  625.                                    (* Check if Alt-S hit again --  *)
  626.                                    (* end transfer if so.          *)
  627.  
  628.          IF ( Esc_Found AND PibTerm_KeyPressed ) THEN
  629.             BEGIN
  630.                Read_Kbd( Ch );
  631.                IF ORD( Ch ) = Alt_S THEN
  632.                   BEGIN
  633.                      Fin       := TRUE;
  634.                      Alt_S_Hit := TRUE;
  635.                   END
  636.                ELSE IF ORD( Ch ) = Shift_Tab THEN
  637.                   Flip_Display_Status
  638.                ELSE
  639.                   Handle_Function_Key( A_Ch );
  640.             END
  641.          ELSE
  642.             WHILE PibTerm_KeyPressed DO
  643.                BEGIN
  644.                   Read_Kbd( Ch );
  645.                   B := Ascii_Receive( A_Ch );
  646.                   Ascii_Send( Ch );
  647.                END;
  648.                                    (* Send the next line to the host *)
  649.          IF ( NOT Fin ) THEN
  650.             Send_Ascii_Line;
  651.                                    (* Update status display *)
  652.  
  653.          INC( Line_Count );
  654.          DEC( Line_Kount );
  655.  
  656.          Byte_Count   := Byte_Count   - Length_Line;
  657.          IF ( Byte_Count < 0 ) THEN
  658.             Byte_Count := 0;
  659.  
  660.          Time_To_Send   := ROUND( Byte_Count / R_Baud_Rate +
  661.                                   R_Char_Delay * Byte_Count +
  662.                                   R_Line_Delay * Line_Kount );
  663.  
  664.          IF Pace_Time THEN
  665.             Time_To_Send := ROUND( Time_To_Send + Line_Kount *
  666.                                    ( Pacing_Delay + R_Line_Delay ) );
  667.  
  668.          IF ( Time_To_Send <= 0 ) THEN
  669.             Time_To_Send := 0;
  670.  
  671.          IF Display_Status THEN
  672.             Update_Ascii_Send_Display;
  673.  
  674.                                    (* Ensure pacing if needed after *)
  675.                                    (* first block                   *)
  676.  
  677.          Pacing := ( Ascii_Pacing_Char <> CHR( NUL ) ) AND
  678.                    ( Ascii_Pacing_Char <> ' '        );
  679.  
  680.                                    (* Look if carrier dropped          *)
  681.  
  682.          Fin := Fin OR Async_Carrier_Drop;
  683.  
  684. 1:
  685.    UNTIL ( Fin OR EOF_AFile );
  686.  
  687.                                    (* Send CtrlZ marker if needed *)
  688.    IF Ascii_Use_CtrlZ THEN
  689.       BEGIN
  690.          B := Ascii_Receive( Ch );
  691.          Ascii_Send( ^Z );
  692.       END;
  693.                                    (* Display any remaining characters while *)
  694.                                    (* waiting for serial output buffer to drain *)
  695.    T1 := TimeOfDay;
  696.  
  697.    WHILE( ( Async_OBuffer_Head <> Async_OBuffer_Tail    ) AND
  698.           ( TimeDiff( T1 , TimeOfDay ) <= Max_Wait_Time ) AND
  699.           ( NOT PibTerm_KeyPressed )                    ) DO
  700.       IF Ascii_Receive( Ch ) THEN
  701.          IF Print_Spooling THEN
  702.             Print_Spooled_File;
  703.  
  704.    DELAY( Two_Second_Delay );
  705.  
  706.                                    (* Ensure status window is up  *)
  707.    IF ( NOT Display_Status ) THEN
  708.       Initialize_Send_Window;
  709.                                    (* Display final transfer time *)
  710.    Activate_Status_Window;
  711.  
  712.    GoToXY( 2 , 9 );
  713.  
  714.    IF ( NOT Fin ) THEN
  715.       BEGIN
  716.  
  717.          Write_Log('Send completed.', TRUE, TRUE );
  718.          GoToXY( 2 , 10 );
  719.  
  720.          TextColor( Menu_Text_Color_2 );
  721.          WRITE (' Actual transfer time was ');
  722.  
  723.          TextColor( Menu_Text_Color );
  724.          WRITE ( TimeString( TimeDiff( Start_Time, TimeOfDay ),
  725.                              Military_Time ) );
  726.       END
  727.    ELSE IF Alt_S_Hit THEN
  728.       Write_Log('Alt-S hit, send stopped.' , TRUE, TRUE )
  729.    ELSE
  730.       Write_Log('Send cancelled.' , TRUE, TRUE );
  731.  
  732.                                    (* Close transferred file           *)
  733.    CLOSE( AFile );
  734.    I := Int24Result;
  735.                                    (* Delay after transfer done.       *)
  736.    Window_Delay;
  737.                                    (* Turn cursor back on *)
  738.    CursorOn;
  739.                                    (* Remove upload buffer           *)
  740.    IF Long_Buffer THEN
  741.       MyFreeMem( Read_Buffer , Buffer_Length );
  742.  
  743.                                    (* Remove this window            *)
  744.  
  745.    Restore_Screen_And_Colors( Saved_Screen );
  746.  
  747. END   (* Send_Ascii_File *);
  748.