From Modula-2 Reloaded

Spec: IO Module BYTE

DEFINITION MODULE BYTE;

(* I/O Module for Type BYTE *)

FROM SYSTEM IMPORT BYTE;
FROM FileIO IMPORT File;

(* EBNF of the textual representation of BYTE values:
    byteValue : simpleFormat |
        cBase16Format | m2Base2Format | m2Base16Format ;
    simpleFormat : ( base16Digit base16Digit )+ ;
    cBase16Format : "0x" simpleFormat ;
    m2Base16Format : "0" simpleFormat "H" ;
    m2Base2Format : ( bit bit bit bit bit bit bit bit )+ "B" ;
    base16Digit : "0" .. "9" | "A" .. "F" ;
    bit : "0" | "1" ; *)

PROCEDURE Read ( infile : File; VAR b : BYTE );
(* Reads the textual representation of a BYTE 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 BYTE argument. *)

PROCEDURE Write ( outfile : File; b : BYTE );
(* Writes the value of BYTE b in simple format to stream outfile. This
   procedure is substituted for invocations of WRITE with a BYTE argument.*)

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

END BYTE.
Retrieved from http://modula-2.net/m2r10/pmwiki.php?n=Spec.IOModuleBYTE
Page last modified on 2010-05-24 12:40