Technical information
Pasterm Serial Solutions
Figure 9-6. Pasterm Main Program._______________________________
BEGIN
{ Variable initialisation section }
ComNo := 0;
ComName := ’COM1’;
Baud := 4; { 1200 Baud}
Parity := 2; { Even}
DataBits := 2; { 7 Bit word length}
StopBits := 0; { 1 stop bit}
Brk := 0; { No break}
Echo := []; { No echo in operation}
Init_Xlt(In_Xlt);
Init_Xlt(Out_Xlt); { Initialise translation tables}
Exec_Defaults; { Find a definition file and execute it}
Open_com; { Open Serial Ports}
WHILE true { Main code is infinite loop}
DO BEGIN
Readin; { Get any characters from port.}
{ Translate and send to display.}
SwitchOut; { Read and process characters from keyboard.}
END;
END.
The first few lines and the procedure Init_Xlt set up
internal variables for use by Pasterm. Exec_Defaults checks for a
command line parameter and attempts to execute the file of
commands to which it refers. If it cannot find the file, or if no
file is specified on the command line then the file
’TERMDEF.TXT’ is tried. Open_Com opens the serial port, as
discussed in the previous section. The program then enters an
infinite loop which alternately calls two procedures, SwitchOut
and Readin.
Readin checks for characters at the serial port, calling the
function InXlat (that is input and translate), which in turn calls
InpStr, discussed in the previous section. If InXlat returns a non-
empty string of characters then Readin prints them out.
SwitchOut polls the keyboard using Kbdinp. A character, if
Chapter 9 Page 149