Technical information

BASterm Serial Solutions
3130 KEY(15) ON
3140 :
3150 KEY OFF ’Turn off key displays at bottom of screen
3160 :
4000 GOSUB 27000 ’Initialise BIOS interface
4010 :
4020 GOSUB 6010 ’Initialise translation tables
4030 :
4040 GOSUB 8010 ’Open file to serial port
4050 :
4060 :
4070 GOSUB 7010 ’Execute definition file
4080 :
4090 :
5000 ’***************************************************************
5010 ’Main program
5020 :
5030 WHILE 1 ’Repeats forever
5040 :
5050 GOSUB 9010 ’Read in characters for port
5060 :
5070 GOSUB 9500 ’Read characters/commands from keyboard
5080 :
5090 WEND ’End infinite loop
5100 :
5110 :
5120 END
5130 :
Lines 2000 to 2380 create the main variables used by the
program. Most are initialised at this point. Lines 3000 to 3160
set up the key traps that the program uses. This rather unusual
feature of PC BASIC allows a predefined subroutine to be
executed when a particular key is hit. BASterm defines
subroutines for function keys F1, F2 and F10, and ALT-C. This
means that the normal program loop need not test for these keys.
The subroutine calls to lines 27000 and 6010 complete the
initialisation of program variables. 27000 is particularly
interesting. It uses an error trap on a statement which is valid
only in QuickBASIC to differentiate between QuickBASIC and
GW-BASIC/BASICA, as different code is needed to manage the
BIOS calls in each language. The serial port is opened at line
4040 (see Figure 10-1). Line 4060, a call to 7010, 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
Chapter 10 Page 161