Go to the first, previous, next, last section, table of contents.
The Fmt Interface converts BOOLEAN, CHAR, INTEGER, and floating point
values to TEXT. The Pad routine also allows justifying TEXT in a field
of spaces or other character.
The following TYPE definitions are used in the formatting routines:
TYPE Base = [2..16];
Style = {Sci, Fix, Auto};
Align = {Left, Right};
- PROCEDURE Bool(b: BOOLEAN): TEXT;
- Format "b" as "TRUE" or "FALSE".
- PROCEDURE Char(c: CHAR): TEXT;
- Return a text containing the character "c".
- PROCEDURE Int(n: INTEGER; base: Base := 10): TEXT;
- PROCEDURE Unsigned(n: Word.T; base: Base := 16): TEXT;
- Format the signed or unsigned number "n" in the specified base. For example:
Fmt.Int(15) = "15"
Fmt.Int(-25) = "-25"
- PROCEDURE Real(num: REAL,style,prec,literal): TEXT
- PROCEDURE LongReal(num: LONGREAL,style,prec,literal): TEXT
- PROCEDURE Extended(num: EXTENDED,style,prec,literal): TEXT
style: Style := Style.Auto;
prec: CARDINAL := R.MaxSignifDigits - 1;
literal := FALSE
Format the floating-point number "num" using "style" with "prec" digits
after the decimal point. If "literal" is TRUE, the result is a legal
Modula-3 literal.
Fmt.Real(5.5678,prec := 2) = "5.57"
- PROCEDURE Pad(text: TEXT; length: CARDINAL; padChar: CHAR := ' ';
align: Align := Align.Right): TEXT;
-
If Text.Length(text) >= length, then "text" is returned unchanged.
Otherwise, "text" is padded with "padChar" until it has the given
"length". The text goes to the right or left, according to "align".
For example:
Fmt.Pad("Info",6) = " Info"
Fmt.Pad("Database",5) = "Database"
Fmt.Pad("15.55",8,'*') = "***15.55"
Go to the first, previous, next, last section, table of contents.