Oberon || Library || Module Index || Search Engine || Definition || Module
CONST tooManyArgs = 0; (* too many arguments given *) CONST tooFewArgs = 1; (* too few arguments given *) CONST badFormat = 2; (* syntax error in format string *) CONST badArgumentSize = 3; (* bad size of argument *) CONST errors = 4; TYPE FormatString = ARRAY 128 OF CHAR; TYPE ErrorCode = SHORTINT; TYPE ErrorEvent = POINTER TO ErrorEventRec; TYPE ErrorEventRec = RECORD (Events.EventRec) errorcode: ErrorCode; format: FormatString; errpos: LONGINT; nargs: INTEGER; END; VAR error: Events.EventType; VAR errormsg: ARRAY errors OF Events.Message;
PROCEDURE F(fmt: ARRAY OF CHAR); PROCEDURE F1(fmt: ARRAY OF CHAR; p1: ARRAY OF BYTE); PROCEDURE F2(fmt: ARRAY OF CHAR; p1, p2: ARRAY OF BYTE); PROCEDURE F3(fmt: ARRAY OF CHAR; p1, p2, p3: ARRAY OF BYTE); PROCEDURE F4(fmt: ARRAY OF CHAR; p1, p2, p3, p4: ARRAY OF BYTE); PROCEDURE F5(fmt: ARRAY OF CHAR; p1, p2, p3, p4, p5: ARRAY OF BYTE); PROCEDURE F6(fmt: ARRAY OF CHAR; p1, p2, p3, p4, p5, p6: ARRAY OF BYTE); PROCEDURE F7(fmt: ARRAY OF CHAR; p1, p2, p3, p4, p5, p6, p7: ARRAY OF BYTE); PROCEDURE F8(fmt: ARRAY OF CHAR; p1, p2, p3, p4, p5, p6, p7, p8: ARRAY OF BYTE); PROCEDURE F9(fmt: ARRAY OF CHAR; p1, p2, p3, p4, p5, p6, p7, p8, p9: ARRAY OF BYTE);
PROCEDURE S(out: Streams.Stream; fmt: ARRAY OF CHAR); PROCEDURE S1(out: Streams.Stream; fmt: ARRAY OF CHAR; p1: ARRAY OF BYTE); PROCEDURE S2(out: Streams.Stream; fmt: ARRAY OF CHAR; p1, p2: ARRAY OF BYTE); PROCEDURE S3(out: Streams.Stream; fmt: ARRAY OF CHAR; p1, p2, p3: ARRAY OF BYTE); PROCEDURE S4(out: Streams.Stream; fmt: ARRAY OF CHAR; p1, p2, p3, p4: ARRAY OF BYTE); PROCEDURE S5(out: Streams.Stream; fmt: ARRAY OF CHAR; p1, p2, p3, p4, p5: ARRAY OF BYTE); PROCEDURE S6(out: Streams.Stream; fmt: ARRAY OF CHAR; p1, p2, p3, p4, p5, p6: ARRAY OF BYTE); PROCEDURE S7(out: Streams.Stream; fmt: ARRAY OF CHAR; p1, p2, p3, p4, p5, p6, p7: ARRAY OF BYTE); PROCEDURE S8(out: Streams.Stream; fmt: ARRAY OF CHAR; p1, p2, p3, p4, p5, p6, p7, p8: ARRAY OF BYTE); PROCEDURE S9(out: Streams.Stream; fmt: ARRAY OF CHAR; p1, p2, p3, p4, p5, p6, p7, p8, p9: ARRAY OF BYTE);
PROCEDURE SE(out: Streams.Stream; fmt: ARRAY OF CHAR; errors: RelatedEvents.Object); PROCEDURE SE1(out: Streams.Stream; fmt: ARRAY OF CHAR; p1: ARRAY OF BYTE; errors: RelatedEvents.Object); PROCEDURE SE2(out: Streams.Stream; fmt: ARRAY OF CHAR; p1, p2: ARRAY OF BYTE; errors: RelatedEvents.Object); PROCEDURE SE3(out: Streams.Stream; fmt: ARRAY OF CHAR; p1, p2, p3: ARRAY OF BYTE; errors: RelatedEvents.Object); PROCEDURE SE4(out: Streams.Stream; fmt: ARRAY OF CHAR; p1, p2, p3, p4: ARRAY OF BYTE; errors: RelatedEvents.Object); PROCEDURE SE5(out: Streams.Stream; fmt: ARRAY OF CHAR; p1, p2, p3, p4, p5: ARRAY OF BYTE; errors: RelatedEvents.Object); PROCEDURE SE6(out: Streams.Stream; fmt: ARRAY OF CHAR; p1, p2, p3, p4, p5, p6: ARRAY OF BYTE; errors: RelatedEvents.Object); PROCEDURE SE7(out: Streams.Stream; fmt: ARRAY OF CHAR; p1, p2, p3, p4, p5, p6, p7: ARRAY OF BYTE; errors: RelatedEvents.Object); PROCEDURE SE8(out: Streams.Stream; fmt: ARRAY OF CHAR; p1, p2, p3, p4, p5, p6, p7, p8: ARRAY OF BYTE; errors: RelatedEvents.Object); PROCEDURE SE9(out: Streams.Stream; fmt: ARRAY OF CHAR; p1, p2, p3, p4, p5, p6, p7, p8, p9: ARRAY OF BYTE; errors: RelatedEvents.Object);
The format string is interpreted as follows: Any character not belonging to an escape sequence introduced by \ or a format element introduced by % is simply appended to Streams.stdout resp. out. Escape sequences are substituted by a single character while format elements are instantiated by the next p? parameter.
Format elements must conform to the following syntax:
FormatElement = "%" {Flags} [Width] [Scale] Conversion . Flags = "+" | "0" | "-" | "^" | "\" FillChar . Width = Number | "*" . Scale = "." Number . Number = { DecDigits } . DecDigits = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" . Conversion = "b" | "c" | "d" | "e" | "f" | "g" | "j" | "o" | "s" | "x" | "y" .
Each format element defines a field in the output stream that is by default as wide as necessary to insert the result of a parameter conversion. The field width can be expanded by specifying Width. If not given as an explicit Number but as * Print uses the value of the next yet unused parameter (interpreted as an integer) as width indication. Values less or equal than the defaults have no effect. In all other cases the output field is filled up by leading blanks. Padding character and alignment strategy may be altered by use of Flags:
Other numeric output is not affected while strings are cut to the length given by Scale before they are aligned within their output fields. Print will use the next yet unused parameter as scale indication if * is specified.
Since Print has no idea about the actual types of the arguments corresponding to its formal parameters, convchar is used to determine the conversions to be executed for the next yet unused parameter. Print will not accept any other conversion character than those listed and described below. In detail the specifications of convchar have the following effect:
Note that o, x, and d are legal conversion characters to output any type which has the same size (in bytes) as the expected one. This feature can be used to output an address (integer size presumed). Furthermore these conversion characters may be used to output the ascii-value of a CHAR. Vice versa c may be used to output a character that is specified by a SHORTINT-value.
%% is not interpreted as a format element. A single percent character is output instead.
Any appearance of the following escape sequences in format string fmt is substituted as listed:
Some calling errors lead to events which are passed to Events (if no errors parameter is given) or to RelatedEvents (by use of SE through SE9). Following error codes are implemented:
Oberon || Library || Module Index || Search Engine || Definition || Module