english
version "1.0"
identify "%Z%%M% %I% %E%"

#: Copyright (c) 1996 by Wayne C. Gramlich.
#, All rights reserved.
#,
#, Permission to use, copy, modify, distribute, and sell this software
#, for any purpose is hereby granted without fee provided that the above
#, copyright notice and this permission are retained.  The author makes
#, no representations about the suitability of this software for any purpose.
#, It is provided "as is" without express or implied warranty.

module errors

#: This module implements an error reporting module:

define errors				#: Errors object
    record
	error_stream out_stream		#: Stream to output errors to
	count unsigned			#: Number of errors
    generate allocate, erase, identical, print

define errors1[type1]			#: Place holder type
    record
	zilch logical
    generate allocate, erase, print

define errors2[type1, type2]		#: Place holder type
    record
	zilch logical
    generate allocate, erase, print

define errors3[type1, type2, type3]	#: Place holder type
    record
	zilch logical
    generate allocate, erase, print



#: {errors} procedures:

procedure xcreate@errors
    takes
	error_stream out_stream
    returns errors

    #: This procedure will create and return a new {errors}.


procedure create@errors
    takes
	error_stream out_stream
    returns errors

    #: This procedure will create and return a new {errors} object.


procedure exist_get@errors
    takes
	errors errors
    returns logical

    #: This procedure will return {true} if {errors} has output any
    #, error messages and {false} otherwise.


procedure reset@errors
    takes
	errors errors
    returns_nothing

    #: This procedure will reset the error count of {errors} to zero.


#: Formatting routines:

procedure format@errors1[type1]
    takes
	errors errors
	message string
	argument1 type1
    returns_nothing
    needs
	procedure format@type1
	    takes type1, out_stream, string, unsigned
	    returns_nothing

    #: This procedure will output {argument1} to {errors} using {message}
    #, to control the formatting.


procedure format@errors2[type1, type2]
    takes
	errors errors
	message string
	argument1 type1
	argument2 type2
    returns_nothing
    needs
	procedure format@type1
	    takes type1, out_stream, string, unsigned
	    returns_nothing
	procedure format@type2
	    takes type2, out_stream, string, unsigned
	    returns_nothing

    #: This procedure will output {argument1} and {argument2} to {errors}
    #, using {message} to control the formatting.


procedure format@errors3[type1, type2, type3]
    takes
	errors errors
	message string
	argument1 type1
	argument2 type2
	argument3 type3
    returns_nothing
    needs
	procedure format@type1
	    takes type1, out_stream, string, unsigned
	    returns_nothing
	procedure format@type2
	    takes type2, out_stream, string, unsigned
	    returns_nothing
	procedure format@type3
	    takes type3, out_stream, string, unsigned
	    returns_nothing

    #: This procedure will output {argument1}, {argument2} and {argument3}
    #, to {errors} using {message} to control the formatting.