-- File: Format.mesa last edit by Johnsson on 26-Jan-81 10:40:00 DIRECTORY LongString USING [SubStringDescriptor], String USING [SubString], Time USING [Packed]; Format: DEFINITIONS = BEGIN OPEN LString: LongString; -- Format various types into strings and call procedure. -- Types StringProc: TYPE = PROCEDURE [s: STRING]; DateFormat: TYPE = {dateOnly, noSeconds, dateTime, full}; NumberFormat: TYPE = RECORD [ base: [2..36], zerofill, unsigned: BOOLEAN, columns: [0..255]]; LongSubStringDescriptor: TYPE = LString.SubStringDescriptor; LongSubString: TYPE = POINTER TO LongSubStringDescriptor; -- Constants OctalFormat: NumberFormat = [ -- 0 columns means use as many as needed. base: 8, zerofill: FALSE, unsigned: TRUE, columns: 0]; DecimalFormat: NumberFormat = [ base: 10, zerofill: FALSE, unsigned: FALSE, columns: 0]; -- Format procedures Char: PROCEDURE [c: CHARACTER, proc: StringProc]; Date: PROCEDURE [pt: Time.Packed, format: DateFormat ← noSeconds, proc: StringProc]; Decimal: PROCEDURE [n: INTEGER, proc: StringProc] = INLINE BEGIN Number[n, DecimalFormat, proc] END; LongDecimal: PROCEDURE [n: LONG INTEGER, proc: StringProc] = INLINE BEGIN LongNumber[n, DecimalFormat, proc]; END; LongNumber: PROCEDURE [n: LONG UNSPECIFIED, format: NumberFormat, proc: StringProc]; LongOctal: PROCEDURE [n: LONG UNSPECIFIED, proc: StringProc]; -- Adds 'B after number. LongString: PROCEDURE [s: LONG STRING, proc: StringProc]; LongSubStringItem: PROCEDURE [ss: LongSubString, proc: StringProc]; -- Repeatedly calls proc with strings filled from ss Number: PROCEDURE [n: UNSPECIFIED, format: NumberFormat, proc: StringProc]; Octal: PROCEDURE[n: UNSPECIFIED, proc: StringProc]; -- Adds 'B after number. SubString: PROCEDURE [ss: String.SubString, proc: StringProc]; -- Repeatedly calls proc with strings filled from ss END. -- Format.mesa