CHAPTER 5
DISK FILE INPUT/OUTPUT
Because
•DIR, which lists the files on a disk
•RENAME, which changes the name of a disk file
•ATTRIB, which changes the attributes of a disk file
•KILL, which deletes a disk file (it is actually the system DELETE command, but the name must be different because
For more information about
Guide.
Although both sequential and random I/O allow you to create, read, and write files on disk, sequential I/O is somewhat simpler in concepts and operation. If you haven't worked with disk files before, it would probably be better to start with se- quential 110 to learn the principles.
Sequential File 1/0
A sequential file is open either for input or output. To switch from one to the other, you must close the file and open it again with the opposite attribute. Any 110 opera- tion that immediately follows an OPEN statement starts at the beginning of the file.
Opening a Sequential File
You open a sequential file with the OPEN statement. It specifies whether the file is to be opened for input or output, assigns it a file number, and specifies the filename. Up to six files can be open at one time. If the file named in an OPEN statement that specifies output does not exist, it is created. Once a file is open, it cannot be opened again without closing it first. If you attempt to do so, an error message results.
To open an input file named :Fl:DATES and assign it file number 1: