Pascal Programming Today by alicejenny

VIEWS: 1 PAGES: 11

									» Procedures involved in writing
  data to files:
  – assign
     – rewrite
     – write
     – close
Pascal Programming Today           1
Chapter 11
» Procedures involved in reading
  data from files:
  – assign
     – reset
     – read
     – close

Pascal Programming Today           2
Chapter 11
 » Variables of type text are used
   to identify files.

Syntax of declaring text files
var
      <File variable> : text;




 Pascal Programming Today            3
 Chapter 11
 » Procedure assign associates file
   variables with files in secondary
   storage.
Syntax of the procedure assign

assign(<File variable>, <File name>)


                            It is a user-defined identifier
                            declared as type text.
 Pascal Programming Today                                 4
 Chapter 11
 » Procedure assign associates file
   variables with files in secondary
   storage.
Syntax of the procedure assign

assign(<File variable>, <File name>)


   May be a string constant of the file name
   or a string variable holding the file name.
 Pascal Programming Today                   5
 Chapter 11
» Procedure rewrite prepares files
  for writing data to them.
» Original data will be lost when
  procedure rewrite is applied to
  the files.


Pascal Programming Today            6
Chapter 11
Syntax of the procedure rewrite

rewrite(<File variable>)




 Pascal Programming Today         7
 Chapter 11
 » Procedure reset prepares files
   for reading data from them.

Syntax of the procedure reset

reset(<File variable>)




 Pascal Programming Today           8
 Chapter 11
    Differences between procedures rewrite and reset



Pascal Programming Today                               9
Chapter 11
 » Procedure close is used to close
   a file.

Syntax of the procedure close

close(<File variable>)




 Pascal Programming Today         10
 Chapter 11
                  Summary of procedures of writing
                 data to and reading data from a file
Pascal Programming Today                                11
Chapter 11

								
To top