Contents | Prev | Next

7.4.20 The get procedure

Description

The get procedure reads the next component from a file into the file's buffer variable (see file type for more information about buffer variables). NOTE: This procedure is seldom used since it is usually easier to use the read or readln procedures.

Parameter

The get procedure's only parameter is a reference to the file variable associated with the file to be read. The file variable must be open before calling this function.

Example

   //********************************************************
   //This program is similar to the unix shell command "cat".
   //It uses the built-in procedures "get" and "put" as well
   // as the file buffer's associated with the input and
   // output file to copy the contents of the input file to
   // the output file.
   program cat(f, g);
   var
      f, g : text;
      c : char;
   begin
      reset(f);
      rewrite(g);
      while not eof(f) do
         begin
            c := f^;
            get(f);
            g^ := c;
            put(g);
         end;
      close(g);
      close(f);
   end.

Portability

Operating Systems: All
Standard Pascal: Yes

Contents | Prev | Next