Writing to a file
OPENFILE <filename> FOR WRITE
WRITEFILE <filename>, <data>
CLOSEFILE <filename>
- Opens a file for writing.
- Writes data into the file.
- Closes the file after writing.
Reading from a file
OPENFILE <filename> FOR READ
READFILE <filename>, <variable>
CLOSEFILE <filename>
- Opens a file for reading.
- Reads a line and stores the value in a variable.
- Closes the file after reading.
Appending to a file
OPENFILE <filename> FOR APPEND
WRITEFILE <filename>, <data>
CLOSEFILE <filename>
- Opens a file for appending.
- Adds new data at the end of the file.
- Closes the file after appending.
Concept of EOF (End of File)
- EOF is used when reading a file from beginning to end.
- It indicates that there is no more data left to read.
- Helps prevent errors when trying to read beyond the file’s content.
No comments:
Post a Comment