Technical information
BASterm Serial Solutions
CLOSE #1 ’Close the file
Because BASICA/GW-BASIC does not have an intrinsic
method of accessing the BIOS, which contains the services
supplied by NewCOM for setting the serial port parameters, and
QuickBASIC does, the two programs use very different pieces of
code to access the BIOS. QuickBASIC uses its ’CALL
INTERRUPT’ statement to access the BIOS. GW-BASIC
/BASICA uses a small machine code routine to achieve the same
effect. Both languages use the same subroutine at line 28000 to
perform the access.
Opening The File_______________
The following subroutine opens the serial port file.
Figure 10-1. Open Subroutine.___________________________
8000 ’***************************************************************
8010 ’Open file to serial port
8020 :
8030 OPEN "R", #1, COMNAME$, 1 ’Random file, record length=1 byte
8040 FIELD #1, 1 AS P$ ’Define P$ as input/output variable
8050 :
8060 RETURN
8070 :
8080 :
Figure 10-1 shows the file number, 1, associated with the serial
port. A random file was used to allow both writing and reading
to and from the port. BASIC sequential files could be used in
restricted applications-they only allow communication in one
direction and are rather inflexible about input formats, but of
course allow data to be formatted and type-converted easily, and
have a simpler syntax.
At this stage the device driver has not been accessed. The
OPEN statement has simply allowed BASIC and DOS to prepare
for I/O to the port, setting up their variables and buffers.
Reading From The File._____________________
The subroutine in Figure 10-2 reads from the serial port.
Chapter 10 Page 155