home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / pibterm / pibt41s1.arc / FASTCHNG.MOD < prev    next >
Text File  |  1987-12-02  |  5KB  |  111 lines

  1. (*----------------------------------------------------------------------*)
  2. (*       Fast_Change_Params --- fast change of communications params.   *)
  3. (*----------------------------------------------------------------------*)
  4.  
  5. PROCEDURE Fast_Change_Params;
  6.  
  7. (*----------------------------------------------------------------------*)
  8. (*                                                                      *)
  9. (*     Procedure:  Fast_Change_Params                                   *)
  10. (*                                                                      *)
  11. (*     Purpose:    Fast change of communications params                 *)
  12. (*                                                                      *)
  13. (*     Calling Sequence:                                                *)
  14. (*                                                                      *)
  15. (*        Fast_Change_Params;                                           *)
  16. (*                                                                      *)
  17. (*                                                                      *)
  18. (*      Remarks:                                                        *)
  19. (*                                                                      *)
  20. (*         This routine is useful is making a fast switch between       *)
  21. (*         the parameter values needed by XMODEM and those required     *)
  22. (*         by the remote host.                                          *)
  23. (*                                                                      *)
  24. (*----------------------------------------------------------------------*)
  25.  
  26. CONST
  27.    Comm_Parities  : ARRAY[ 1 .. 5 ] OF CHAR    = ( 'N','E','O','M','S' );
  28.    Comm_Data_Bits : ARRAY[ 1 .. 5 ] OF INTEGER = (  8,  7,  7,  7,  7  );
  29.    Baud_Rates     : ARRAY[ 1 .. 5  ] OF WORD
  30.                     = ( 300, 1200, 2400, 9600, 19200 );
  31.    Letters        : ARRAY[1..25] OF CHAR
  32.                     = ( 'a','f','k','p','u',
  33.                         'b','g','l','q','v',
  34.                         'c','h','m','r','w',
  35.                         'd','i','n','s','x',
  36.                         'e','j','o','t','y'  );
  37.  
  38. VAR
  39.    I               : INTEGER;
  40.    J               : INTEGER;
  41.    Let             : INTEGER;
  42.    Local_Save      : Saved_Screen_Ptr;
  43.    OK_Choice       : BOOLEAN;
  44.    Ch              : CHAR;
  45.  
  46. BEGIN (* Fast_Change_Params *)
  47.                                    (* Draw frame around screen *)
  48.  
  49.    Draw_Titled_Box( Local_Save, 1, 5, 79, 14,
  50.                     'Change communications settings' );
  51.  
  52.    PibTerm_Window( 2, 6, 78, 13 );
  53.                                    (* Display params to choose from *)
  54.    Let := 0;
  55.  
  56.    FOR I := 1 TO 5 DO
  57.       BEGIN
  58.          GoToXY( 2 , I );
  59.          FOR J := 1 TO 5 DO
  60.             BEGIN
  61.                Let := Let + 1;
  62.                TextColor( Menu_Text_Color_2 );
  63.                WRITE( Letters[ Let ] );
  64.                TextColor( Menu_Text_Color  );
  65.                WRITE( ') ' );
  66.                WRITE( Baud_Rates[J]:5,',',Comm_Data_Bits[I],',',
  67.                       Comm_Parities[I],',1 ' );
  68.             END;
  69.       END;
  70.                                    (* Get new params *)
  71.    REPEAT
  72.       GoToXY( 2 , 7 );
  73.       TextColor( Menu_Text_Color_2 );
  74.       WRITE ( 'Enter letter corresponding to new parameters or ESC to quit: ');
  75.       TextColor( Menu_Text_Color );
  76.       Read_Kbd( Ch );
  77.       Ch := UpCase( Ch );
  78.       OK_Choice := ( Ch = CHR( ESC ) ) OR
  79.                    ( Ch = CHR( CR  ) ) OR
  80.                    ( ( ORD( Ch ) >= ORD( 'A' ) ) AND
  81.                      ( ORD( Ch ) <= ORD( 'Y' ) ) );
  82.       IF ( NOT OK_Choice ) THEN
  83.          Menu_Beep;
  84.    UNTIL ( OK_Choice );
  85.                                    (* Get parameters corresponding *)
  86.                                    (* to choice.                   *)
  87.  
  88.    IF ( ( Ch <> CHR( ESC ) ) AND ( Ch <> CHR( CR ) ) ) THEN
  89.       BEGIN
  90.  
  91.          Let := ORD( Ch ) - ORD( 'A' );
  92.          J   := ( Let DIV 5 ) + 1;
  93.          I   := ( Let MOD 5 ) + 1;
  94.  
  95.          Baud_Rate := Baud_Rates    [J];
  96.          Parity    := Comm_Parities [I];
  97.          Data_Bits := Comm_Data_Bits[I];
  98.          Stop_Bits := 1;
  99.                                    (* Reset the port *)
  100.  
  101.          Async_Reset_Port( Comm_Port, Baud_Rate, Parity, Data_Bits, Stop_Bits );
  102.  
  103.          Reset_Comm_Port := TRUE;
  104.  
  105.       END;
  106.                                    (* Restore previous screen *)
  107.  
  108.    Restore_Screen_And_Colors( Local_Save );
  109.  
  110. END   (* Fast_Change_Params *);
  111.