Modula-2 Reloaded

A Modern Typesafe & Literate Programming Notation

Site Menu

Project

Specification

Implementation

Recommendations

Reference

Needs Updating

Work in Progress

Wastebasket

Wiki Manual

edit SideBar

Text IO

DEFINITION MODULE TextIO;

  (* Input and output of character and string types with specified files.
     The file status is of the type File.FileStatus. *)

IMPORT File;

  (* The following procedures read only until an endOfLine state is set. The file status is set
      to the value allRight, outOfRange, endOfLine, or endOfInput. *)

PROCEDURE ReadChar (file : File; VAR ch : CHAR);
 (* Reads the next character from the file fid before an and of line mark and stores it in 'ch'. *)

PROCEDURE ReadString (fid: File; VAR s: ARRAY OF CHAR);
  (* Removes only those characters from the input file fid before the next line mark that can
      be accommodated in s as a string value, and copies them to s. *)

PROCEDURE ReadToken (fid: File; VAR s: ARRAY OF CHAR);
  (* Skips leading spaces, and then removes characters from the input file fid before the next
      space or line mark, copying to s as many as can be accommodated as a string value. *)

PROCEDURE ReadLine (fid: File; VAR s: ARRAY OF CHAR);
  (* Removes any remaining characters from the input file fid before the next line mark,
      copying to s as many as can be accommodated as a string value.  *)

  (* The following procedure reads past the next line mark *)

PROCEDURE SkipLine (fid: File);
  (* Removes successive items from the input file fid up to and including the next endOfLine
      and clears that state, or until the end of input is reached. The file status is set to the
      value allRight or endOfInput.  *)

  (* Output procedures *)

PROCEDURE WriteChar(file : File; ch : CHAR);
  (* Writes the char in 'ch' to the file fid. *)

PROCEDURE WriteLn (fid: File);
  (* Writes the implementation defined endOfLine to the output file fid. *)

PROCEDURE WriteString (fid: File; s: ARRAY OF CHAR);
  (* Writes the characters in s to the output file fid. *)

END TextIO.