English
Language : 

NSB8 Datasheet, PDF (111/158 Pages) List of Unclassifed Manufacturers – BASIC interpreter for Z80 family
ITALIAN TECHNOLOGY
grifo®
10 REM Report contents of sequential data file of unknown structure.
20 REM Assume no string bigger than 500 chars.
30 DIM S$(500),F$(10)
40 REM F$ will hold file name, S$ will hold string values read and N will hold numbers read.
70 INPUT “TYPE NAME OF FILE TO READ: “,F$
80 OPEN #1,F$
90 IF TYP(1)=0 THEN 240
100 REM Above is endmark check.
110 IF TYP(1)=2 THEN 190
120 REM Above checks if number is next. If not, string is next.
140 REM READ and PRINT string.
150 READ #1,S$
160 PRINT S$
170 REM Go back for more data.
180 GOTO 90
190 REM READ and PRINT number.
200 READ #1,N
210 PRINT N
220 REM Get more data.
230 GOTO 90
240 REM No more data.
250 PRINT “** END OF FILE **”
260 CLOSE #1
270 END
The following sample program writes the numbers 1 to 10 to existing data file “DAT7”, then reads
them back and prints them on the terminal. Note that, after writing, the file is closed and reopened
in order to begin reading at the start, since the last executed write statement leaves BASIC looking
at the endmark.
10 REM WRITE 10 numbers to file and READ them back again.
30 REM First, WRITE them!
40 OPEN #1, “DAT7”
50 FOR I=1 TO 10
60 WRITE #1,I
70 NEXT
80 CLOSE #1
90 REM Now, READ and PRINT.
100 OPEN #1, “DAT7”
110 IF TYP(1)=0 THEN 170
120 REM Above checks for endmark.
130 READ #1,I
140 PRINT I
150 REM Now back for next number.
160 GOTO 110
170 REM Quit.
180 PRINT “** END OF FILE **”
190 CLOSE #1
200 END
NSB8
Rel. 5.10
Page 99