The reset procedure


The reset procedure associates a file variable with a file (i.e. opens the file variable and allows it to be used to manipulate the file). The reset procedure opens the file variable in read-only mode. The open procedure can also be used to open file variables in read-only mode.


  1. The first parameter is a reference to the file variable to be opened.
  2. The second parameter is an expression of string type or char type, and names the file variable, referenced by the first parameter, as if the built-in procedure assign had been called. NOTE: This parameter is an extension to Standard Pascal.
The name of the file variable, referenced by the first parmater, controls which file is opened by the reset procedure. If the name is a non-empty string then a file with that name is opened. If the name is an empty string then the file opened is either the standard output file, or a temporary file (with a system generated name), depending on the project options set when the program was compiled.

File variables can get named in the following ways:


The program below is used to count the number of vowels and the total number of characters in the input file. If you run this program and don't supply a program argument like

  ivm vowels

then the program reads from the standad input file. If you run this program with a program argument like

  ivm vowels filename

then the program will open the file named filename and read from it.

program vowels(f, output);
   f : file of char;
   tot, vow : integer;
   c : char;
   reset(f);  //Open the input file in readmode.
   tot := 0;  //Initialize total number of chars read so far
   vow := 0;  //Initialize total number of vowels read so far
   while not eof(f) do
         read(f, c);  //Read character
         case c of
            'a', 'e', 'i', 'o', 'u',
            'A', 'E', 'I', 'O', 'U'
               : vow := vow + 1;
            otherwise //include "otherwise" so that non-vowels don't cause errors.
         tot := tot + 1;
   writeln('Total characters read = ', tot);
   writeln('Vowels read = ', vow)


Operating Systems: All
Standard Pascal: Yes