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

#: Copyright (c) 1993-2005 by Wayne C. Gramlich.
#, All rights reserved.

module format

#: This module implements a generic formating routine akin to printf for C:

define format
    record
	zilch logical
    generate allocate, erase, print

define format0
    record
	zilch logical
    generate allocate, erase, print

define format1[type1]
    record
	zilch logical
    generate allocate, erase, print

define format2[type1, type2]
    record
	zilch logical
    generate allocate, erase, print

define format3[type1, type2, type3]
    record
	zilch logical
    generate allocate, erase, print

define format4[type1, type2, type3, type4]
    record
	zilch logical
    generate allocate, erase, print

define format5[type1, type2, type3, type4, type5]
    record
	zilch logical
    generate allocate, erase, print

define format6[type1, type2, type3, type4, type5, type6]
    record
	zilch logical
    generate allocate, erase, print

define format7[type1, type2, type3, type4, type5, type6, type7]
    record
	zilch logical
    generate allocate, erase, print

define format8[type1, type2, type3, type4, type5, type6, type7, type8]
    record
	zilch logical
    generate allocate, erase, print

define format9[type1, type2, type3, type4, type5, type6, type7, type8, type9]
    record
	zilch logical
    generate allocate, erase, print


procedure munch@format
    takes
	out_stream out_stream
	message string
	offset unsigned
	argument_number unsigned
    returns unsigned, unsigned, unsigned


procedure format@format0
    takes
	out_stream out_stream
	message string
    returns_nothing


procedure format@format1[type1]
    takes
	out_stream out_stream
	message string
	argument1 type1
    returns_nothing
    needs
	procedure format@type1
	    takes type1, out_stream, string, unsigned
	    returns_nothing
	procedure print@type1
	    takes type1, out_stream
	    returns_nothing


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


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


procedure format@format4[type1, type2, type3, type4]
    takes
	out_stream out_stream
	message string
	argument1 type1
	argument2 type2
	argument3 type3
	argument4 type4
    returns_nothing
    needs
	procedure format@type1
	    takes type1, out_stream, string, unsigned
	    returns_nothing
	procedure print@type1
	    takes type1, out_stream
	    returns_nothing
	procedure format@type2
	    takes type2, out_stream, string, unsigned
	    returns_nothing
	procedure print@type2
	    takes type2, out_stream
	    returns_nothing
	procedure format@type3
	    takes type3, out_stream, string, unsigned
	    returns_nothing
	procedure print@type3
	    takes type3, out_stream
	    returns_nothing
	procedure format@type4
	    takes type4, out_stream, string, unsigned
	    returns_nothing
	procedure print@type4
	    takes type4, out_stream
	    returns_nothing


procedure format@format5[type1, type2, type3, type4, type5]
    takes
	out_stream out_stream
	message string
	argument1 type1
	argument2 type2
	argument3 type3
	argument4 type4
	argument5 type5
    returns_nothing
    needs
	procedure format@type1
	    takes type1, out_stream, string, unsigned
	    returns_nothing
	procedure print@type1
	    takes type1, out_stream
	    returns_nothing
	procedure format@type2
	    takes type2, out_stream, string, unsigned
	    returns_nothing
	procedure print@type2
	    takes type2, out_stream
	    returns_nothing
	procedure format@type3
	    takes type3, out_stream, string, unsigned
	    returns_nothing
	procedure print@type3
	    takes type3, out_stream
	    returns_nothing
	procedure format@type4
	    takes type4, out_stream, string, unsigned
	    returns_nothing
	procedure print@type4
	    takes type4, out_stream
	    returns_nothing
	procedure format@type5
	    takes type5, out_stream, string, unsigned
	    returns_nothing
	procedure print@type5
	    takes type5, out_stream
	    returns_nothing


procedure format@format6[type1, type2, type3, type4, type5, type6]
    takes
	out_stream out_stream
	message string
	argument1 type1
	argument2 type2
	argument3 type3
	argument4 type4
	argument5 type5
	argument6 type6
    returns_nothing
    needs
	procedure format@type1
	    takes type1, out_stream, string, unsigned
	    returns_nothing
	procedure print@type1
	    takes type1, out_stream
	    returns_nothing
	procedure format@type2
	    takes type2, out_stream, string, unsigned
	    returns_nothing
	procedure print@type2
	    takes type2, out_stream
	    returns_nothing
	procedure format@type3
	    takes type3, out_stream, string, unsigned
	    returns_nothing
	procedure print@type3
	    takes type3, out_stream
	    returns_nothing
	procedure format@type4
	    takes type4, out_stream, string, unsigned
	    returns_nothing
	procedure print@type4
	    takes type4, out_stream
	    returns_nothing
	procedure format@type5
	    takes type5, out_stream, string, unsigned
	    returns_nothing
	procedure print@type5
	    takes type5, out_stream
	    returns_nothing
	procedure format@type6
	    takes type6, out_stream, string, unsigned
	    returns_nothing
	procedure print@type6
	    takes type6, out_stream
	    returns_nothing


procedure format@format7[type1, type2, type3, type4, type5, type6, type7]
    takes
	out_stream out_stream
	message string
	argument1 type1
	argument2 type2
	argument3 type3
	argument4 type4
	argument5 type5
	argument6 type6
	argument7 type7
    returns_nothing
    needs
	procedure format@type1
	    takes type1, out_stream, string, unsigned
	    returns_nothing
	procedure print@type1
	    takes type1, out_stream
	    returns_nothing
	procedure format@type2
	    takes type2, out_stream, string, unsigned
	    returns_nothing
	procedure print@type2
	    takes type2, out_stream
	    returns_nothing
	procedure format@type3
	    takes type3, out_stream, string, unsigned
	    returns_nothing
	procedure print@type3
	    takes type3, out_stream
	    returns_nothing
	procedure format@type4
	    takes type4, out_stream, string, unsigned
	    returns_nothing
	procedure print@type4
	    takes type4, out_stream
	    returns_nothing
	procedure format@type5
	    takes type5, out_stream, string, unsigned
	    returns_nothing
	procedure print@type5
	    takes type5, out_stream
	    returns_nothing
	procedure format@type6
	    takes type6, out_stream, string, unsigned
	    returns_nothing
	procedure print@type6
	    takes type6, out_stream
	    returns_nothing
	procedure format@type7
	    takes type7, out_stream, string, unsigned
	    returns_nothing
	procedure print@type7
	    takes type7, out_stream
	    returns_nothing


procedure format@format8[type1, type2, type3,
  type4, type5, type6, type7, type8]
    takes
	out_stream out_stream
	message string
	argument1 type1
	argument2 type2
	argument3 type3
	argument4 type4
	argument5 type5
	argument6 type6
	argument7 type7
	argument8 type8
    returns_nothing
    needs
	procedure format@type1
	    takes type1, out_stream, string, unsigned
	    returns_nothing
	procedure print@type1
	    takes type1, out_stream
	    returns_nothing
	procedure format@type2
	    takes type2, out_stream, string, unsigned
	    returns_nothing
	procedure print@type2
	    takes type2, out_stream
	    returns_nothing
	procedure format@type3
	    takes type3, out_stream, string, unsigned
	    returns_nothing
	procedure print@type3
	    takes type3, out_stream
	    returns_nothing
	procedure format@type4
	    takes type4, out_stream, string, unsigned
	    returns_nothing
	procedure print@type4
	    takes type4, out_stream
	    returns_nothing
	procedure format@type5
	    takes type5, out_stream, string, unsigned
	    returns_nothing
	procedure print@type5
	    takes type5, out_stream
	    returns_nothing
	procedure format@type6
	    takes type6, out_stream, string, unsigned
	    returns_nothing
	procedure print@type6
	    takes type6, out_stream
	    returns_nothing
	procedure format@type7
	    takes type7, out_stream, string, unsigned
	    returns_nothing
	procedure print@type7
	    takes type7, out_stream
	    returns_nothing
	procedure format@type8
	    takes type8, out_stream, string, unsigned
	    returns_nothing
	procedure print@type8
	    takes type8, out_stream
	    returns_nothing


procedure format@format9[type1, type2, type3,
  type4, type5, type6, type7, type8, type9]
    takes
	out_stream out_stream
	message string
	argument1 type1
	argument2 type2
	argument3 type3
	argument4 type4
	argument5 type5
	argument6 type6
	argument7 type7
	argument8 type8
	argument9 type9
    returns_nothing
    needs
	procedure format@type1
	    takes type1, out_stream, string, unsigned
	    returns_nothing
	procedure print@type1
	    takes type1, out_stream
	    returns_nothing
	procedure format@type2
	    takes type2, out_stream, string, unsigned
	    returns_nothing
	procedure print@type2
	    takes type2, out_stream
	    returns_nothing
	procedure format@type3
	    takes type3, out_stream, string, unsigned
	    returns_nothing
	procedure print@type3
	    takes type3, out_stream
	    returns_nothing
	procedure format@type4
	    takes type4, out_stream, string, unsigned
	    returns_nothing
	procedure print@type4
	    takes type4, out_stream
	    returns_nothing
	procedure format@type5
	    takes type5, out_stream, string, unsigned
	    returns_nothing
	procedure print@type5
	    takes type5, out_stream
	    returns_nothing
	procedure format@type6
	    takes type6, out_stream, string, unsigned
	    returns_nothing
	procedure print@type6
	    takes type6, out_stream
	    returns_nothing
	procedure format@type7
	    takes type7, out_stream, string, unsigned
	    returns_nothing
	procedure print@type7
	    takes type7, out_stream
	    returns_nothing
	procedure format@type8
	    takes type8, out_stream, string, unsigned
	    returns_nothing
	procedure print@type8
	    takes type8, out_stream
	    returns_nothing
	procedure format@type9
	    takes type9, out_stream, string, unsigned
	    returns_nothing
	procedure print@type9
	    takes type9, out_stream
	    returns_nothing