I. OPEN
It is used to open a file or a device.
Syntax:
It has two syntaxes
OPEN "file mode", #Fileno., "data file name"
OPEN "data file name" FOR modeName AS #fileno.
Example
OPEN "O", #1, "STUDENT.DAT"
OPEN "STUDENT.DAT" FOR OUTPUT AS #1
II. WRITE#
It is used to write data into a file or a device.
Syntax:
Write #Fileno. , <list of variables>
Example
WRITE #1, NAM$, CLASS, ROLL, SEC$
III. INPUT#
It is used to read data from a data file.
Syntax:
INPUT #FileNo., <list of variables>
Example
Input #1, NAM$, CLASS, ROLL, SEC$
IV. LINE INPUT#
It is used to read data from a data file using a string variable. It is similar to the INPUT# statement but it reads the entire record buffer using a string variable instead of a list of variables.
Syntax:
LINE INPUT #Fileno., string variable
Example
LINE INPUT #1, RECO$
V. CLOSE
It is used to close all opened files.
Syntax:
CLOSE [#Fileno.1, #Fileno.2,......#File no "n"]
Example
CLOSE #1...Closes only single file with #1
CLOSE #1,#2...Closes both #1 and #2 files.
VI. EOF()
It means End of file. It is used to check the end of file position in the data file.
Syntax:
EOF (Fileno.)
Example
If EOF (1) THEN CLOSE #1
VII. PRINT#
It is similar to WRITE# statement. It writes data into the file without the delimiters. Thus, the output differs from WRITE# statement.
Syntax:
PRINT #Fileno., <list of variables>
Example
PRINT #1, NAM$, CLASS, ROLL, SEC$