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

IO Module BOOLEAN

DEFINITION MODULE BOOLEAN;

(* I/O Module for Type BOOLEAN *)

FROM FileIO IMPORT File;

(* EBNF of the textual representation of BOOLEAN values:
    boolValue : trueFalseFormat | yesNoFormat ;
    trueFalseFormat : "TRUE" | "FALSE" ;
    yesNoFormat : "YES" | "NO" ; *)

PROCEDURE Read ( infile : File; VAR b : BOOLEAN );
(* Reads the textual representation of a BOOLEAN value from stream infile
   - any leading whitespace is skipped
   - any remaining characters that are part of the value being read are
     removed from infile
   - the textual representation of the value read is assigned to b
   - the file status is set to any of:
     success, outOfRange, wrongFormat, endOfLine, or endOfInput. This
   procedure is substituted for invocations of READ with a BOOLEAN argument.*)

PROCEDURE Write ( outfile : File; b : BOOLEAN );
(* Writes the textual representation of BOOLEAN b to stream outfile. This
   procedure is substituted for invocations of WRITE with a BOOLEAN argument.*)

PROCEDURE WriteF ( outfile      : File;
                   CONST fmtStr : ARRAY OF CHAR;
                   items        : VARIADIC OF BOOLEAN );
(* Writes a formatted textual representation of one or more BOOLEAN values to
   output stream outfile. The output format is determined by fmtStr. This
   procedure is substituted for invocations of WRITEF with one or more
   BOOLEAN arguments. *)

END BOOLEAN.