In this lecture we will see how to read file from disk
The general format is as
open file _name access permission
access is the access mode
r.... open the file for reading . The file must b present.r+...open a file for reading and writing.
w.. open the file for writing. create the file if it is not present.
w+.. open file for reading and writing.. create if not present.
a.. open file for writing . it must be present their.
a+.. open file for writing and create it if not present their.
permission :
permission is an integer to use to set the file access permissionsclose fileID:
closes the file that has been already created.
gets fileID varnamee:
reads a line from fileID and discards the terminating newline.puts ? -nonewline? fileID string
writes in file.
Examples:
i have a file abc.text in this location \hoome\masroor.
a:
set ns
open \home\masroor\abc r
returns file3 which is file id
now i will use this id to close file
close file3
b:
open /home/masroor/abc w+
puts file4 "i hate this "
close file4