Type
Module with library wide common types.
Types
DATETIME* = HUGEINT;
STRING* = POINTER TO ARRAY OF CHAR;
Stream* = RECORD
error* : INTEGER;
END;
Procedures
Stream.HasError
PROCEDURE (VAR s : Stream) HasError*(): BOOLEAN;
Stream.LastError
Return last error code or OK if no error is set.
PROCEDURE (VAR s : Stream) LastError*(): LONGINT;
Stream.ClearError
Clear error status to OK.
PROCEDURE (VAR s : Stream) ClearError*();
Stream.ReadBytes
Read bytes into buffer with start and length.
PROCEDURE (VAR s : Stream) ReadBytes*(VAR buffer : ARRAY OF BYTE; start, length : LENGTH): LENGTH;
Stream.ReadByte
Read BYTE value. Return TRUE if success.
PROCEDURE (VAR s : Stream) ReadByte*(VAR value : BYTE): BOOLEAN;
Stream.ReadChar
Read CHAR value. Return TRUE if success.
PROCEDURE (VAR s : Stream) ReadChar*(VAR value : CHAR): BOOLEAN;
Stream.ReadInteger
Read INTEGER value. Return TRUE if success.
PROCEDURE (VAR s : Stream) ReadInteger*(VAR value : INTEGER): BOOLEAN;
Stream.ReadLongInt
Read LONGINT value. Return TRUE if success.
PROCEDURE (VAR s : Stream) ReadLongInt*(VAR value : LONGINT): BOOLEAN;
Stream.ReadReal
Read REAL value. Return TRUE if success.
PROCEDURE (VAR s : Stream) ReadReal*(VAR value : REAL): BOOLEAN;
Stream.ReadLongReal
Read LONGREAL value. Return TRUE if success.
PROCEDURE (VAR s : Stream) ReadLongReal*(VAR value : LONGREAL): BOOLEAN;
Stream.ReadLine
Read line to EOL mark or EOF mark. STRING possible reallocated to contain whole line if needed. Return TRUE if success.
PROCEDURE (VAR s : Stream) ReadLine*(VAR value : STRING): BOOLEAN;
Stream.WriteBytes
Write bytes from buffer with start and length.
PROCEDURE (VAR s : Stream) WriteBytes*(VAR buffer : ARRAY OF BYTE; start, length: LENGTH): LENGTH;
Stream.WriteByte
Write BYTE value. Sets error to ErrorWriteFailed on failure.
PROCEDURE (VAR s : Stream) WriteByte*(value : BYTE);
Stream.WriteChar
Write CHAR value. Sets error to ErrorWriteFailed on failure.
PROCEDURE (VAR s : Stream) WriteChar*(value : CHAR);
Stream.WriteInteger
Write INTEGER value. Sets error to ErrorWriteFailed on failure.
PROCEDURE (VAR s : Stream) WriteInteger*(value : INTEGER);
Stream.WriteLongInt
Write LONGINT value. Sets error to ErrorWriteFailed on failure.
PROCEDURE (VAR s : Stream) WriteLongInt*(value : LONGINT);
Stream.WriteReal
Write REAL value. Sets error to ErrorWriteFailed on failure.
PROCEDURE (VAR s : Stream) WriteReal*(value : REAL);
Stream.WriteLongReal
Write LONGREAL value. Sets error to ErrorWriteFailed on failure.
PROCEDURE (VAR s : Stream) WriteLongReal*(value : LONGREAL);
Stream.WriteString
Write ARRAY OF CHAR value to NULL byte or length of array. Sets error to ErrorWriteFailed on failure.
PROCEDURE (VAR s : Stream) WriteString*(str- : ARRAY OF CHAR);
Stream.WriteNL
Write platforms newline value to stream. Sets error to ErrorWriteFailed on failure.
PROCEDURE (VAR s : Stream) WriteNL*();
Stream.WriteStream
Write Stream src to stream. Sets error to ErrorWriteFailed on failure.
PROCEDURE (VAR s : Stream) WriteStream*(VAR src : Stream);
Stream.Seek
Offsets or set the current location depending on the mode argument:
SeekSet : sets position relative to start of stream.
SeekCur : sets position relative to current position of stream.
SeekEnd : sets position relative to end position of stream (only negative offset values makes sense).
Return new position or -1 in case of failure.
PROCEDURE (VAR s : Stream) Seek*(offset : LENGTH; mode : INTEGER): LENGTH;
Stream.Tell
Return current position or -1 on failure.
PROCEDURE (VAR s : Stream) Tell*(): LENGTH;
Stream.Truncate
Truncates or extends stream to new size. Return new size or -1 in case of failure.
PROCEDURE (VAR s : Stream) Truncate*(size : LENGTH): LENGTH;
Stream.Flush
Flush buffers
PROCEDURE (VAR s : Stream) Flush*();
Stream.Close
Close Stream
PROCEDURE (VAR s : Stream) Close*();
Stream.Closed
Return TRUE if Stream is closed
PROCEDURE (VAR s : Stream) Closed*(): BOOLEAN;
Stream.IsTTY
Return TRUE if Stream is a TTY
PROCEDURE (VAR s : Stream) IsTTY*(): BOOLEAN;
Stream.Readable
Return TRUE if Stream is readable
PROCEDURE (VAR s : Stream) Readable*(): BOOLEAN;
Stream.Writeable
Return TRUE if Stream is writeable
PROCEDURE (VAR s : Stream) Writeable*(): BOOLEAN;
Stream.Seekable
Return TRUE if Stream is seekable
PROCEDURE (VAR s : Stream) Seekable*(): BOOLEAN;
Stream.FormatString
Format ARRAY OF CHAR.
width : Total field with. Can overflow if string is bigger.
prec : The number of characters in string to add (if prec > 0)
The alignment formatting flags are Left, Right & Center . The Upper flag will make the whole string upper case. The Alt flag will capitalize the string.
PROCEDURE (VAR s : Stream) FormatString*(str- : ARRAY OF CHAR; width, prec: INTEGER; flags: SET);
Stream.FormatInteger
Format HUGEINT.
width : Total field with. Can overflow if number is bigger.
The alignment formatting flags are Left, Right & Center . The Zero flag fills with 0 of the formatting is right aligned. The Spc flag fills in a blank character for + if the number is positive. The Sign flag fills in a + character if the number is positive. If both Spc and Sign are given then Sign precedes.
PROCEDURE (VAR s : Stream) FormatInteger*(value : HUGEINT; width: LENGTH; flags: SET);
Stream.FormatReal
Format REAL.
prec : Precision or zero for default value.
width : Total field with. Can overflow if number is bigger.
flags : Exp or Fix formatting supported.
The alignment formatting flags are Left, Right & Center . The Spc flag fills in a blank character for + if the number is positive. The Sign flag fills in a + character if the number is positive. If both Spc and Sign are given then Sign precedes.
PROCEDURE (VAR s : Stream) FormatReal*(value : REAL; prec : INTEGER; width: LENGTH; flags: SET);
Stream.FormatCardinal
Format HUGECARD.
base : Number base.
width : Total field with. Can overflow if number is bigger.
The alignment formatting flags are Left, Right & Center . The Zero flag fills with 0 of the formatting is right aligned. The Upper flag the hex decimal letters are upper case.
The Alt flags prefix binary (base 2) numbers with 0b, octal numbers (base 8) with 0o and hex decimal numbers with either 0x or 0X depending on the Upper flag.
PROCEDURE (VAR s : Stream) FormatCardinal*(value : HUGECARD; base, width: INTEGER; flags: SET);
Stream.FormatDateTime
Format DATETIME according to format string arguments:
%a : Weekday abbreviated name : Mon .. Sun
%A : Weekday full name : Monday .. Sunday
%w : Weekday as number : 0 .. 6
%b : Month abbreviated name : Jan .. Des
%B : Month full name : Januar .. Desember
%Y : Year without century : 00 - 99
%y : Year with century : 0000 - 9999
%m : Month zero-padded : 00 - 12
%d : Day of the month zero-padded : 01 - XX
%W : Week of the year zero-padded : 01 - 53
%H : Hour (24-hour clock) zero-padded : 00 - 23
%I : Hour (12-hour clock) zero-padded : 1 - 12
%p : AM or PM
%M : Minute zero-padded : 00 - 59
%S : Second zero-padded : 00 - 59
%f : Milliseconds zero-padded : 000 - 999
%Z : Timezone : UTC+/-
%% : Literal % char
Other characters are copied to output.
PROCEDURE (VAR s : Stream) FormatDateTime*(value : DATETIME; fmt- : ARRAY OF CHAR);