home *** CD-ROM | disk | FTP | other *** search
- (*----------------------------------------------------------------------*)
- (* Set_Params --- Set Communications Parameters *)
- (*----------------------------------------------------------------------*)
-
- Function Set_Params( First_Time : Boolean ) : Boolean;
-
- (* *)
- (* Function: Set_Params *)
- (* *)
- (* Purpose: Ask for and set communications parameters *)
- (* *)
- (* Calling Sequence: *)
- (* *)
- (* Flag := Set_Params( First_Time ) : Boolean; *)
- (* *)
- (* First_Time: TRUE for initial setup, else FALSE. *)
- (* Flag is TRUE if successful set-up, else FALSE. *)
- (* *)
- (* Calls: ClrScr *)
- (* Async_Init *)
- (* Async_Open *)
- (* Menu_Get_Choice *)
- (* Menu_Display_Choices *)
- (* *)
-
- (* Constants for Communications Parameter Values *)
- Const
-
- Baud_Rates: Array[ 1 .. 8 ] OF Integer
- = ( 110, 150, 300, 600, 1200, 2400, 4800, 9600 );
-
- Parities: Array[ 1 .. 3 ] OF Char
- = ( 'E', 'O', 'N' );
-
- Stop_Data: Array[ 1 .. 2 ] OF Integer
- = ( 1 , 2 );
-
- Char_Bits: Array[ 1 .. 2 ] Of Integer
- = ( 7 , 8 );
-
- Term_Data: Array[ 1 .. 2 ] Of Terminal_Type
- = ( Dumb , VT52 );
-
- (* Menu Variables *)
- Var
- Port_Menu : Menu_Type;
- Baud_Menu : Menu_Type;
- Parity_Menu : Menu_Type;
- Stop_Menu : Menu_Type;
- Bits_Menu : Menu_Type;
- BS_Menu : Menu_Type;
- Emul_Menu : Menu_Type;
- I : Integer;
-
-
- Begin (* Set_Params *)
-
- (* Select Default Parameters *)
- If First_Time Then
- Begin
- Data_Bits := 7;
- Parity := 'E';
- Stop_Bits := 1;
- Baud_Rate := 1200;
- Comm_Port := 1;
- BS_Char := CHR( BS );
- Ctrl_BS_Char := CHR( DEL );
- Terminal_To_Emulate := VT52;
- End;
-
- (* Get port number *)
- Port_Menu.Menu_Size := 2;
- Port_Menu.Menu_Default := Comm_Port;
- Port_Menu.Menu_Row := 11;
- Port_Menu.Menu_Column := 30;
- Port_Menu.Menu_Tcolor := Menu_Text_Color;
- Port_Menu.Menu_Bcolor := BackGround_Color;
- Port_Menu.Menu_Fcolor := Menu_Frame_Color;
- Port_Menu.Menu_Width := 0;
- Port_Menu.Menu_Height := 0;
-
- For I := 1 to 2 Do
- With Port_Menu.Menu_Entries[I] Do
- Begin
- Menu_Item_Row := I;
- Menu_Item_Column := 2;
- Case I Of
- 1: Menu_Item_Text:= 'Serial Port 1';
- 2: Menu_Item_Text:= 'Serial Port 2';
- End (* Case *);
- End;
-
- Port_Menu.Menu_Title := 'Which Communications Port: ';
-
- Menu_Display_Choices( Port_Menu );
- Comm_Port := Menu_Get_Choice( Port_Menu , Erase_Menu );
-
- (* Get Baud Rate *)
- Baud_Menu.Menu_Size := 8;
- Baud_Menu.Menu_Row := 11;
- Baud_Menu.Menu_Column := 30;
- Baud_Menu.Menu_Tcolor := Menu_Text_Color;
- Baud_Menu.Menu_Bcolor := BackGround_Color;
- Baud_Menu.Menu_Fcolor := Menu_Frame_Color;
- Baud_Menu.Menu_Width := 0;
- Baud_Menu.Menu_Height := 0;
-
- Case Baud_Rate Of
- 110 : Baud_Menu.Menu_Default := 1;
- 150 : Baud_Menu.Menu_Default := 2;
- 300 : Baud_Menu.Menu_Default := 3;
- 600 : Baud_Menu.Menu_Default := 4;
- 1200: Baud_Menu.Menu_Default := 5;
- 2400: Baud_Menu.Menu_Default := 6;
- 4800: Baud_Menu.Menu_Default := 7;
- 9600: Baud_Menu.Menu_Default := 8;
- End (* Case *);
-
- For I := 1 to 8 Do
- With Baud_Menu.Menu_Entries[I] Do
- Begin
- Menu_Item_Row := I;
- Menu_Item_Column := 2;
- Case I Of
- 1: Menu_Item_Text:= '110';
- 2: Menu_Item_Text:= '150';
- 3: Menu_Item_Text:= '300';
- 4: Menu_Item_Text:= '600';
- 5: Menu_Item_Text:= '1200';
- 6: Menu_Item_Text:= '2400';
- 7: Menu_Item_Text:= '4800';
- 8: Menu_Item_Text:= '9600';
- End (* Case *);
- End;
-
- Baud_Menu.Menu_Title := 'Choose Baud Rate: ';
-
- Menu_Display_Choices( Baud_Menu );
- Baud_Rate := Baud_Rates[ Menu_Get_Choice( Baud_Menu , Erase_Menu ) ];
-
- (* Get Bits per Character *)
- Bits_Menu.Menu_Size := 2;
- Bits_Menu.Menu_Default := Data_Bits - 6;
- Bits_Menu.Menu_Row := 11;
- Bits_Menu.Menu_Column := 30;
- Bits_Menu.Menu_Tcolor := Menu_Text_Color;
- Bits_Menu.Menu_Bcolor := BackGround_Color;
- Bits_Menu.Menu_Fcolor := Menu_Frame_Color;
- Bits_Menu.Menu_Width := 0;
- Bits_Menu.Menu_Height := 0;
-
- For I := 1 to 2 Do
- With Bits_Menu.Menu_Entries[I] Do
- Begin
- Menu_Item_Row := I;
- Menu_Item_Column := 2;
- Case I Of
- 1: Menu_Item_Text:= '7';
- 2: Menu_Item_Text:= '8';
- End (* Case *);
- End;
-
- Bits_Menu.Menu_Title := 'Data Bits in Each Character: ';
-
- Menu_Display_Choices( Bits_Menu );
- Data_Bits := Char_Bits[ Menu_Get_Choice( Bits_Menu , Erase_Menu ) ];
-
- (* Get stop bits *)
- Stop_Menu.Menu_Size := 2;
- Stop_Menu.Menu_Default := Stop_Bits;
- Stop_Menu.Menu_Row := 11;
- Stop_Menu.Menu_Column := 30;
- Stop_Menu.Menu_Tcolor := Menu_Text_Color;
- Stop_Menu.Menu_Bcolor := BackGround_Color;
- Stop_Menu.Menu_Fcolor := Menu_Frame_Color;
- Stop_Menu.Menu_Width := 0;
- Stop_Menu.Menu_Height := 0;
-
- For I := 1 to 2 Do
- With Stop_Menu.Menu_Entries[I] Do
- Begin
- Menu_Item_Row := I;
- Menu_Item_Column := 2;
- Case I Of
- 1: Menu_Item_Text:= '1';
- 2: Menu_Item_Text:= '2';
- End (* Case *);
- End;
-
- Stop_Menu.Menu_Title := 'Number of Stop Bits: ';
-
- Menu_Display_Choices( Stop_Menu );
- Stop_Bits := Stop_Data[ Menu_Get_Choice( Stop_Menu , Erase_Menu ) ];
-
- (* Get Parity *)
- Parity_Menu.Menu_Size := 3;
-
- Case Parity Of
- 'E' : Parity_Menu.Menu_Default := 1;
- 'O' : Parity_Menu.Menu_Default := 2;
- 'N' : Parity_Menu.Menu_Default := 3;
- End (* Case *);
-
- Parity_Menu.Menu_Row := 11;
- Parity_Menu.Menu_Column := 30;
- Parity_Menu.Menu_Tcolor := Menu_Text_Color;
- Parity_Menu.Menu_Bcolor := BackGround_Color;
- Parity_Menu.Menu_Fcolor := Menu_Frame_Color;
- Parity_Menu.Menu_Width := 0;
- Parity_Menu.Menu_Height := 0;
-
- For I := 1 to 3 Do
- With Parity_Menu.Menu_Entries[I] Do
- Begin
- Menu_Item_Row := I;
- Menu_Item_Column := 2;
- Case I Of
- 1: Menu_Item_Text:= 'Even';
- 2: Menu_Item_Text:= 'Odd';
- 3: Menu_Item_Text:= 'None';
- End (* Case *);
- End;
-
- Parity_Menu.Menu_Title := 'Choose Parity: ';
-
- Menu_Display_Choices( Parity_Menu );
- Parity := Parities[ Menu_Get_Choice( Parity_Menu , Erase_Menu ) ];
-
- (* Get BackSpace Key Use *)
- BS_Menu.Menu_Size := 2;
- BS_Menu.Menu_Row := 11;
- BS_Menu.Menu_Column := 30;
- BS_Menu.Menu_Tcolor := Menu_Text_Color;
- BS_Menu.Menu_Bcolor := BackGround_Color;
- BS_Menu.Menu_Fcolor := Menu_Frame_Color;
- BS_Menu.Menu_Width := 0;
- BS_Menu.Menu_Height := 0;
-
- If BS_Char = CHR( BS ) Then
- BS_Menu.Menu_Default := 1
- Else
- BS_Menu.Menu_Default := 2;
-
- For I := 1 To 2 Do
- With BS_Menu.Menu_Entries[I] Do
- Begin
- Menu_Item_Row := I;
- Menu_Item_Column := 2;
- Case I Of
- 1: Menu_Item_Text:= 'Backspace (ASCII 08)';
- 2: Menu_Item_Text:= 'Delete (ASCII 127)';
- End (* Case *);
- End;
-
- BS_Menu.Menu_Title := 'Backspace key sends: ';
-
- Menu_Display_Choices( BS_Menu );
-
- Case Menu_Get_Choice( BS_Menu, Erase_Menu ) Of
-
- 1: Begin
- BS_Char := CHR( BS );
- Ctrl_BS_Char := CHR( DEL );
- End;
-
- 2: Begin
- BS_Char := CHR( DEL );
- Ctrl_BS_Char := CHR( BS );
- End;
-
- End (* Case *);
-
- (* Get terminal type to emulate *)
- Emul_Menu.Menu_Size := 2;
-
- Case Terminal_To_Emulate Of
- Dumb: Emul_Menu.Menu_Default := 1;
- VT52: Emul_Menu.Menu_Default := 2;
- End (* Case *);
-
- Emul_Menu.Menu_Row := 11;
- Emul_Menu.Menu_Column := 30;
- Emul_Menu.Menu_Tcolor := Menu_Text_Color;
- Emul_Menu.Menu_Bcolor := BackGround_Color;
- Emul_Menu.Menu_Fcolor := Menu_Frame_Color;
- Emul_Menu.Menu_Width := 0;
- Emul_Menu.Menu_Height := 0;
-
- For I := 1 to 2 Do
- With Emul_Menu.Menu_Entries[I] Do
- Begin
- Menu_Item_Row := I;
- Menu_Item_Column := 2;
- Case I Of
- 1: Menu_Item_Text:= 'Dumb';
- 2: Menu_Item_Text:= 'VT52';
- End (* Case *);
- End;
-
- Emul_Menu.Menu_Title := 'Terminal to emulate: ';
-
- Menu_Display_Choices( Emul_Menu );
- Terminal_To_Emulate := Term_Data[ Menu_Get_Choice( Emul_Menu , Erase_Menu ) ];
-
- (* Initialize Comm Variables *)
- Async_Init;
- (* Open Communications Port *)
-
- Set_Params := Async_Open( Comm_Port, Baud_Rate, Parity, Data_Bits,
- Stop_Bits );
-
- If First_Time Then ClrScr;
-
- End (* Set_Params *);