2020-05-25 22:48:33 +02:00
|
|
|
(*
|
2020-10-13 09:58:51 +02:00
|
|
|
BSD 2-Clause License
|
2020-05-25 22:48:33 +02:00
|
|
|
|
2020-10-13 09:58:51 +02:00
|
|
|
Copyright (c) 2020, Anton Krotov
|
|
|
|
All rights reserved.
|
2020-05-25 22:48:33 +02:00
|
|
|
*)
|
|
|
|
|
|
|
|
MODULE Out;
|
|
|
|
|
2020-10-13 09:58:51 +02:00
|
|
|
IMPORT SYSTEM;
|
2020-05-25 22:48:33 +02:00
|
|
|
|
|
|
|
|
|
|
|
VAR
|
|
|
|
|
2020-10-13 09:58:51 +02:00
|
|
|
hConsoleOutput: INTEGER;
|
2020-05-25 22:48:33 +02:00
|
|
|
|
|
|
|
|
2020-10-13 09:58:51 +02:00
|
|
|
PROCEDURE [ccall, "msvcrt.dll", "printf"] printf1 (fmt: INTEGER; x: INTEGER);
|
|
|
|
PROCEDURE [ccall, "msvcrt.dll", "printf"] printf2 (fmt: INTEGER; width, x: INTEGER);
|
|
|
|
PROCEDURE [ccall, "msvcrt.dll", "printf"] printf3 (fmt: INTEGER; width, precision: INTEGER; x: REAL);
|
2020-05-25 22:48:33 +02:00
|
|
|
|
2020-10-13 09:58:51 +02:00
|
|
|
PROCEDURE [windows, "kernel32.dll", ""]
|
|
|
|
WriteConsoleW (hConsoleOutput, lpBuffer, nNumberOfCharsToWrite, lpNumberOfCharsWritten, lpReserved: INTEGER);
|
|
|
|
|
|
|
|
PROCEDURE [windows, "kernel32.dll", ""]
|
|
|
|
GetStdHandle (nStdHandle: INTEGER): INTEGER;
|
2020-05-25 22:48:33 +02:00
|
|
|
|
2020-10-13 09:58:51 +02:00
|
|
|
|
|
|
|
PROCEDURE Char* (x: CHAR);
|
2020-05-25 22:48:33 +02:00
|
|
|
BEGIN
|
2020-10-13 09:58:51 +02:00
|
|
|
printf1(SYSTEM.SADR("%c"), ORD(x))
|
2020-05-25 22:48:33 +02:00
|
|
|
END Char;
|
|
|
|
|
|
|
|
|
2020-10-13 09:58:51 +02:00
|
|
|
PROCEDURE StringW* (s: ARRAY OF WCHAR);
|
2020-05-25 22:48:33 +02:00
|
|
|
BEGIN
|
2020-10-13 09:58:51 +02:00
|
|
|
WriteConsoleW(hConsoleOutput, SYSTEM.ADR(s[0]), LENGTH(s), 0, 0)
|
|
|
|
END StringW;
|
2020-05-25 22:48:33 +02:00
|
|
|
|
|
|
|
|
2020-10-13 09:58:51 +02:00
|
|
|
PROCEDURE String* (s: ARRAY OF CHAR);
|
2020-05-25 22:48:33 +02:00
|
|
|
BEGIN
|
2020-10-13 09:58:51 +02:00
|
|
|
printf2(SYSTEM.SADR("%.*s"), LENGTH(s), SYSTEM.ADR(s[0]))
|
|
|
|
END String;
|
2020-05-25 22:48:33 +02:00
|
|
|
|
|
|
|
|
|
|
|
PROCEDURE Ln*;
|
|
|
|
BEGIN
|
2020-10-13 09:58:51 +02:00
|
|
|
printf1(SYSTEM.SADR("%s"), SYSTEM.SADR(CHR(13) + CHR(10)))
|
2020-05-25 22:48:33 +02:00
|
|
|
END Ln;
|
|
|
|
|
2020-10-13 09:58:51 +02:00
|
|
|
|
|
|
|
PROCEDURE Int* (x, width: INTEGER);
|
2020-05-25 22:48:33 +02:00
|
|
|
BEGIN
|
2020-10-13 09:58:51 +02:00
|
|
|
printf2(SYSTEM.SADR("%*d"), width, x)
|
|
|
|
END Int;
|
2020-05-25 22:48:33 +02:00
|
|
|
|
|
|
|
|
2020-10-13 09:58:51 +02:00
|
|
|
PROCEDURE Real* (x: REAL; width: INTEGER);
|
2020-05-25 22:48:33 +02:00
|
|
|
BEGIN
|
2020-10-13 09:58:51 +02:00
|
|
|
printf3(SYSTEM.SADR("%*.*E"), width, MAX(MIN(width - 8, 15), 1), x)
|
2020-05-25 22:48:33 +02:00
|
|
|
END Real;
|
|
|
|
|
2020-10-13 09:58:51 +02:00
|
|
|
|
|
|
|
PROCEDURE FixReal* (x: REAL; width, precision: INTEGER);
|
2020-05-25 22:48:33 +02:00
|
|
|
BEGIN
|
2020-10-13 09:58:51 +02:00
|
|
|
printf3(SYSTEM.SADR("%*.*f"), width, precision, x)
|
2020-05-25 22:48:33 +02:00
|
|
|
END FixReal;
|
|
|
|
|
2020-10-13 09:58:51 +02:00
|
|
|
|
2020-05-25 22:48:33 +02:00
|
|
|
PROCEDURE Open*;
|
|
|
|
BEGIN
|
2020-10-13 09:58:51 +02:00
|
|
|
hConsoleOutput := GetStdHandle(-11)
|
2020-05-25 22:48:33 +02:00
|
|
|
END Open;
|
|
|
|
|
2020-10-13 09:58:51 +02:00
|
|
|
|
2020-05-25 22:48:33 +02:00
|
|
|
END Out.
|