Technical information

Forterm Serial Solutions
end
The first few lines or the main program and the subroutine
initxlt set up internal variables for use by Forterm. 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 subroutines, 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
entered, is compared with zero. A zero byte indicates an
extended character code, used for the function keys, cursor and
edit keys and ALT key combinations. These are all taken to be
commands, and so the procedure Menuout is called to deal with
them. All other keys are echoed (if echo to screen has been set),
and then passed on to outxlat. Outxlat translates the characters
and uses Outstr to send them on to the serial port. Outstr is
examined in the section above.
Menuout deals with the function keys and the ALT-C key.
It reads the second byte of the extended key code and interprets
it as a request to perform a certain action, calls cmdout for help,
quit and commands, and Setup for the setup option. Cmdout
decodes a character string as a command (whether the string is
from the keyboard, a file or a literal in the program does not
matter), calling one of the command execution routines to do the
actual work. Setup presents the user with a group of menus to
set up the serial port. It gets options from the user and calls the
command execution routines to perform them.
Note the use of the subroutine screen throughout for output
to the screen. This subroutine at this time simply calls write, but
is used so that future versions of Forterm can easily use separate
windows or a marking scheme to separate the three type of text
Chapter 11 Page 171