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