Radio Shack TRS-80 Model 100 Basic Manual page 178

Basic language lab
Hide thumbs Also See for TRS-80 Model 100:
Table of Contents

Advertisement

Line 49 Execution jumps to line 20 to allow another name to be entered. Lines 20
through 40 form an infinite loop.
Experiment #6 Input from the COM: device
The procedure to input from the serial port is quite similar, as illustrated by changing
the previous program as follows:
Enter Edit Mode and change lines 20 and 30 to
20 INPUT #1, N$
30 PRINT N$
Before executing the program, make sure the peripheral device is properly connected
to the serial port and ready to transmit a string of characters. The string should be
terminated with a comma or a carriage return and a line feed.
Execute this program, then have the peripheral device send a string. If everything is
working properly, you will see the string which was sent from the peripheral device
displayed on the Model 100.
Since the program loops back to the INPUT statement, you can have the peripheral
device send as many strings as you wish. You will have to press
(BREAK)
to terminate
the program.
Experiment #7 Interrupt from the COM: device
You can interrupt execution of a BASIC program from the serial port. This can be
very useful to allow communications with a peripheral device which transmits data at
unpredictable times. For example, a lab instrument might send test results sporadically
as they are completed. Using the interrupt capability, you could use the Model 100 to
run a BASIC program, yet still capture the data from the instrument whenever it is
sent.
If
you have another terminal, such as another computer or a CRT terminal, you might
try the following experiment which will serve to illustrate the concept.
Clear memory with the NEW command and enter
10 OPEN "COM:37010" FOR INPUT AS 1
20 ON COM GOSUB 100
30 COM ON
a0
PRINT I : 1=1+1 : GOTO
a0
100 PRINT INPUT$ (111) : RETURN
Execute this program. You will see numbers starting at zero and incrementing by one
displayed along the left margin. These numbers will continue to print until a character
is received through the serial port. When this happens, the character received will also
be displayed.
If
a string of characters is received through the serial port they will all be displayed
before the program continues printing the numbers.
172

Advertisement

Table of Contents
loading

Table of Contents