Diagnostic Programs
BASIC Code Listings
TERMINAL PROGRAM

4000 REM ==== PROGRAM 10.1 ====
4005 REM ==== TERMINAL PROGRAM ====
4020 S$ = "": GOSUB 4800: REM Set serial parameters
4025 IF S$ = "" THEN 4599
4040 OPEN S$ FOR RANDOM AS #1
4050 ON COM(N%) GOSUB 4600
4060 COM(N%) ON
4070 CLS : PRINT "Type CTRL/Q for 'quick brown fox', CTRL/Z to quit"
4080 LOCATE , , 1
4100 REM ==== MAIN PROGRAM ====
4120 K$ = INKEY$: IF K$ = "" THEN 4120
4130 K% = ASC(K$)
4140 IF K% = 26 THEN 4200
4150 IF K% = 17 THEN PRINT #1, "The quick brown fox jumps over the lazy dog": GOTO 4120
4160 PRINT #1, K$;
4170 GOTO 4120
4200 PRINT : INPUT "Exit Terminal (Y/N) "; K$
4220 IF K$ = "Y" OR K$ = "y" THEN 4240
4230 GOTO 4120
4240 COM(N%) OFF
4599 END
4600 L% = LOC(1): IF L% = 0 THEN RETURN
4610 PRINT INPUT$(L%, #1);
4620 RETURN
4800 REM ==== SET SERIAL PARAMETERS ====
4810 CLS
4820 INPUT "Choose serial port: 0) Quit 1) COM1 2) COM2 "; N%
4821 IF N% > 2 THEN 4820
4822 IF N% = 0 THEN RETURN
4823 IF N% = 1 THEN S$ = "COM1:"
4824 IF N% = 2 THEN S$ = "COM2:"
4830 INPUT "Choose speed: 1) 300 2) 1200 3) 2400 4) 4800 5) 9600 "; I%
4831 IF I% < 1 OR I% > 5 THEN 4830
4832 IF I% = 1 THEN S$ = S$ + "300,"
4833 IF I% = 2 THEN S$ = S$ + "1200,"
4834 IF I% = 3 THEN S$ = S$ + "2400,"
4835 IF I% = 4 THEN S$ = S$ + "4800,"
4836 IF I% = 5 THEN S$ = S$ + "9600,"
4840 INPUT "Choose data format: 1) 8-N-1 2) 7-E-1 3) 7-O-1 "; I%
4841 IF I% < 1 OR I% > 3 THEN 4840
4842 IF I% = 1 THEN S$ = S$ + "N,8,1"
4843 IF I% = 2 THEN S$ = S$ + "E,7,1"
4844 IF I% = 3 THEN S$ = S$ + "O,7,1"
4850 RETURN