A short program from Bob Mitchell’s tutorial on OPEN #, CLOSE #, channels and streams. GO TO 10 walks the channel information area from CHANS and prints each channel’s letter with its output and input routine addresses, then shows where each of the 16 streams points, or CLOSED. GO TO 200 PEEKs the 38 bytes of stream data in the system variables, and GO TO 220 lists the channel area byte by byte up to the start of the program. It works on the TS2068 or the Spectrum.
The notes printed at the right of each line (after a semicolon) are annotations, not part of the program, and are left out of the tape. Line 130 saves the program with the Larken disk system (RANDOMIZE USR 100: SAVE “chans.B1”) and is not needed on tape. As printed, line 230 has PEEK i=>32 where >= is meant, so GO TO 220 prints the first byte and stops with C Nonsense in BASIC.
Published in Sinc-Link September-October 1988 (Bob’s Notebook: Tutorial on Open, Close, Channels & Streams).
Source Code
3 REM This program works in either TS2068 or Spectrum
5 REM ====================
6 REM Use GO TO 10 for info on channels & streams.
7 REM Use GO TO 200 to PEEK stream info in system variables. Use GO TO 220 to PEEK channel info area up to start of program area.
9 REM ====================
10 LET a=PEEK 23631+256*PEEK 23632: LET b=a ;start of CHANS from sys variables
20 IF PEEK a=128 THEN GO TO 70 ;last byte in table
30 PRINT "CHANNEL ";CHR$ (PEEK (a+4)) ;channel letter
40 PRINT "Output Address=";PEEK a+256*PEEK (a+1) ;output address
50 PRINT "Input Address=";PEEK (a+2)+256*PEEK (a+3) ;input address.
60 PRINT : LET a=a+5: GO TO 20
70 FOR a=23574 TO 23605 STEP 2
80 PRINT "Stream ";(a-23574)/2;TAB 10; ;stream number.
90 IF PEEK a+256*PEEK (a+1)=0 THEN PRINT "CLOSED": NEXT a: STOP ;closed channel
100 LET c=(PEEK a+256*PEEK (a+1))+b+3 ;channel letter
110 PRINT "points to Channel ";CHR$ PEEK c: NEXT a
120 STOP
130 RANDOMIZE USR 100: SAVE "chans.B1" LINE 10 ;Larken SAVE routine
140 STOP
200 FOR i=23568 TO 23605: PRINT i,PEEK i: NEXT i ;addresses of channels attached to streams.
210 STOP
220 LET prog=PEEK 23635+256*PEEK 23636 ;start of prog area
230 FOR i=b TO prog-1: PRINT i,PEEK i;TAB 20;CHR$ PEEK i AND PEEK i=>32 AND PEEK i<=90: NEXT i ;examines chan info area up to start of prog areaNote: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.

