Opening a File: When creating a sequential file,the first thing the programmer must do is open the file using the open statement.The open statement has the following form:OPEN"file Name.ext"FOR mode AS#[buffer].The OPEN statement will provide the name of the file,the way in which it will be used ,and the buffer number of the file.The same rule apply for the naming data files as they do for naming "regular"BASIC program files,except a data file should normally be given an extension ).ext) of .DAT where as a program file is given an extension of .BAS.
WRTITING TO A FILE:Writting to a file that has been previously opened in OUTPUT mode is accomplished using the write # statement works much like the print statement,except instead of sending output to the screen,the WRITE # statement will send data to the opend file .Another difference is that when using the WRITE# statement, you must first indicate the buffer number of the file being written to .For example,consider the following WRITE# statement:
WRITE#1,name,address,phone READING FROM a File: Reading data from a file that has been previously opened as INPUT is accomplished using the INPUT# statement.The INPUT # statement is similar to the INPUT statement,except instead of reading user data input from the keyboard,the INPUT# statement reads data input from a file on disk .For example,consider the following: INPUT#1,stuName,gpa,grade