English
Language : 

NSB8 Datasheet, PDF (112/158 Pages) List of Unclassifed Manufacturers – BASIC interpreter for Z80 family
grifo®
ITALIAN TECHNOLOGY
APPENDING TO SEQUENTIAL FILES
To add new data to the end of an existing sequential file, it is necessary to READ to the endmark
before beginning to WRITE. If the sequential file “DAT7” already contains the numbers 1 to 10, then
the following program will add the numbers 11 to 20 to its end.
10 REM ADD 11-20 to DAT7 file.
20 OPEN #1,”DAT7”
30 REM Now READ to endmark.
40 IF TYP(1)=0 THEN 70
50 READ #1,N
60 GOTO 40
70 REM Now add the numbers.
80 FOR I=11 TO 20
90 WRITE #1,I
100 NEXT
110 REM Quit.
120 PRINT “DONE”
130 CLOSE #1
140 END
SEQUENTIAL BYTE ACCESS
Files may also be accessed at the byte by byte level simply by using the ampersand character (&) to
prefix variables into which values will be read, or to prefix expressions to be written:
10 REM READ a byte value, then WRITE one.
20 REM OPEN DAT7 file with file number 1.
30 OPEN #1,”DAT7”
40 REM First byte goes into X.
50 READ #1, &X
60 REM Byte value 65 goes to file #1.
70 WRITE #1,&65
80 CLOSE modified file
90 CLOSE #1
100 END
Only numeric expressions and variables may be given the & prefix. Byte values are integers in the
range 0÷255, and naturally, since BASIC automatically converts from decimal to binary and back,
each consumes only one byte of file storage space. You should be sure that any value you intend to
WRITE as a byte to a file lies in the legal byte range.
Note than an endmark will always be written after the last data item in a WRITE statement., whether
or not that last item is a byte value. To disable writing of the endmark, use the NOENDMARK option
in your WRITE statements.
Page 100
NSB8
Rel. 5.10