File Access Cancellation And How To Detect File End - Sharp MZ-80B Basic Manual

Personal computer double precision disc
Hide thumbs Also See for MZ-80B:
Table of Contents

Advertisement

1. 5 File access cancellation and how to detect file end

1.5.1
KILL
# n
This st at ement, when i t follows t he WOPEN st at ement, cancels t he WOPEN command.
The execut ion of KILL st at ement cancels t he WOPEN and prevent s t he dat a array, even if it is
u nder const r u ct ion, from being recorded in t he sequ ent ial access file. The st at ement is pract ical if t he
need for cancellat ion occu rs du ring t he const r u ct ion of a sequ ent ial dat a array.
The KILL st at ement for t he ot her u se has same f u nct ions as t he CLOSE st at ement .
1.5.1
How to detect file e n d
What is t he resu lt when t he nu mber of dat a reads exceeds t he nu mber of recorded it ems? In s u ch
cases, no error occu rs and t he variables are set wit h 0 or "nu ll", t hen a special f u nct ion, EOF (#n),
det ect s file end . EOF ( #n), becomes "true" if it comes to the end of a file while data is being read
with the INP UT # statement. Hence, if t he st at ement
I F EOF (#n) THEN
is placed af t er an INPUT # st at ement, inst ru ct ions follo wing THEN are execut ed when EOF (#n)
becomes t r u e (when t he file end is det ect ed).
The st at ement can be u sed in a random access file or a sequ ent ial access file to be read.
The following program reads st ring dat a from sequ ent ial access f ile "ABC" and displays it on t he
CRT screen u nt il t he file end is reached .
3 00 ROPEN #3 3, "ABC"
3 1 0 INPUT #3 3, A$
3 2 0 I F EOF (#33) THEN 3 5 0
3 3 0 PRINT A $
3 40 GOTO 3 1 0
3 5 0 CLOSE #3 3
1 1

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents