Oberon || Library || Module Index || Search Engine || Definition || Module


Ulm's Oberon Library:
BoolDisciplines


NAME

BoolDisciplines - aliases of TRUE and FALSE

SYNOPSIS

PROCEDURE InclTrue(obj: Disciplines.Object; name: ARRAY OF CHAR);
PROCEDURE InclFalse(obj: Disciplines.Object; name: ARRAY OF CHAR);
PROCEDURE ExclTrue(obj: Disciplines.Object; name: ARRAY OF CHAR);
PROCEDURE ExclFalse(obj: Disciplines.Object; name: ARRAY OF CHAR);
PROCEDURE IsTrue(obj: Disciplines.Object; name: ARRAY OF CHAR) : BOOLEAN;
PROCEDURE IsFalse(obj: Disciplines.Object; name: ARRAY OF CHAR) : BOOLEAN;
PROCEDURE CreateIterator(VAR it: Iterators.Iterator;
                         obj: Disciplines.Object;
                         bool: BOOLEAN);

DESCRIPTION

BoolDisciplines maintains alias names for TRUE and FALSE on base of a discipline which may be attached to any extension of Disciplines.Object. BoolDisciplines is particularly useful when reading BOOLEAN values from a stream.

InclTrue and InclFalse allow to add alias names for TRUE and FALSE, respectively. ExclTrue and ExclFalse remove an alias name entered before by InclTrue or InclFalse. Initial alias names are "TRUE" for TRUE and "FALSE" for FALSE.

IsTrue and IsFalse test name for being an alias for TRUE or FALSE, respectively. CreateIterator returns an iterator which returns all alias names for bool as ConstStrings.String.

EXAMPLE

Following example shows how a BOOLEAN value may be read in:
PROCEDURE ReadBool(s: Streams.Stream; VAR boolval: BOOLEAN) : BOOLEAN;
   VAR
      name: ARRAY 32 OF CHAR;
BEGIN
   IF ~Read.FieldS(s, name) THEN RETURN FALSE END;
   IF BoolDisciplines.IsTrue(s, name) THEN
      boolval := TRUE; RETURN TRUE
   ELSIF BoolDisciplines.IsFalse(s, name) THEN
      boolval := FALSE; RETURN TRUE
   ELSE
      (* unknown name *)
      RETURN FALSE
   END;
END ReadBool;
The callee of ReadBool may then decide to add "yes" and "no" to the default names "TRUE" and "FALSE":
BoolDisciplines.InclTrue(s, "yes");
BoolDisciplines.InclFalse(s, "no");
IF ReadBool(s, boolval) THEN
   (* ... *)
END;

SEE ALSO

BoolArgs
depends on this module
Disciplines
access of auxiliary data structures
Read
reading a field or a string from a stream
StreamDisciplines
general set of stream parameters

Edited by: borchert, last change: 1995/04/13, revision: 1.1, converted to HTML: 1997/04/28

Oberon || Library || Module Index || Search Engine || Definition || Module