Technical information
Serial Solutions BASterm
Figure 10-2. Input Subroutine.___________________________
9000 ’***************************************************************
9010 ’Read characters from port, send to screen
9020 :
9030 ON ERROR GOT 9300
9040 :
9050 GET #1 ’Attempt read
9060 :
9070 IF EOF(1) THEN RETURN ’Eof ==> none read
9080 :
9090 ON ERROR GOTO 0
9100 :
9110 BUFFER$ = P$
9120 :
9130 ’If echo to line then send to serial port
9140 IF ECHO AND ECHOL THEN GOSUB 10010
9150 :
9160 ’Translate character
9170 BUFFER$ = INXLT$(ASC(BUFFER$))
9180 :
9190 ’Output to screen
9200 FOR I = 1 TO LEN(BUFFER$)
9210 IF MID$(BUFFER$, I, 1) = CHR$(10) THEN PRINT : GOTO 9190
9220 PRINT MID$(BUFFER$, I, 1);
9230 NEXT I
9240 :
9250 RETURN
9260 :
9300 ’Input error handler
9310 :
9320 RESUME 9340
9330 :
9340 ON ERROR GOTO 0
9350 :
9360 RETURN
9370 :
9380 :
The GET statement forces BASIC to access the driver, and
the character returned is held in P$. At this first access of the
port for a read or write that the NewCOM driver itself is
actually accessed. NewCOM sets up its internal buffers, which
are essential for interrupt driven I/O, and initialises the serial
hardware. The EOF function is used to check whether the driver
can return any data. The subroutine also handles echo to line (by
calling the output subroutine), translates the character read and
Page 156 Chapter 10