2019-03-11 11:59:55 +03:00
|
|
|
(*
|
|
|
|
BSD 2-Clause License
|
2016-10-24 02:30:27 +03:00
|
|
|
|
2019-03-11 11:59:55 +03:00
|
|
|
Copyright (c) 2018, 2019, Anton Krotov
|
|
|
|
All rights reserved.
|
2016-10-24 02:30:27 +03:00
|
|
|
*)
|
|
|
|
|
|
|
|
MODULE UTILS;
|
|
|
|
|
2019-03-11 11:59:55 +03:00
|
|
|
IMPORT HOST, UNIXTIME;
|
|
|
|
|
2016-10-24 02:30:27 +03:00
|
|
|
|
|
|
|
CONST
|
|
|
|
|
2019-03-11 11:59:55 +03:00
|
|
|
slash* = HOST.slash;
|
2016-10-24 02:30:27 +03:00
|
|
|
|
2019-03-11 11:59:55 +03:00
|
|
|
bit_depth* = HOST.bit_depth;
|
|
|
|
maxint* = HOST.maxint;
|
|
|
|
minint* = HOST.minint;
|
|
|
|
|
|
|
|
OS = HOST.OS;
|
2016-10-24 02:30:27 +03:00
|
|
|
|
|
|
|
|
2019-03-11 11:59:55 +03:00
|
|
|
VAR
|
2016-10-24 02:30:27 +03:00
|
|
|
|
2019-03-11 11:59:55 +03:00
|
|
|
time*: INTEGER;
|
2016-10-24 02:30:27 +03:00
|
|
|
|
2019-03-11 11:59:55 +03:00
|
|
|
eol*: ARRAY 3 OF CHAR;
|
2016-10-24 02:30:27 +03:00
|
|
|
|
2019-03-11 11:59:55 +03:00
|
|
|
maxreal*: REAL;
|
2016-10-24 02:30:27 +03:00
|
|
|
|
|
|
|
|
2019-03-11 11:59:55 +03:00
|
|
|
PROCEDURE FileRead* (F: INTEGER; VAR Buffer: ARRAY OF BYTE; bytes: INTEGER): INTEGER;
|
|
|
|
RETURN HOST.FileRead(F, Buffer, bytes)
|
|
|
|
END FileRead;
|
2016-10-24 02:30:27 +03:00
|
|
|
|
|
|
|
|
2019-03-11 11:59:55 +03:00
|
|
|
PROCEDURE FileWrite* (F: INTEGER; Buffer: ARRAY OF BYTE; bytes: INTEGER): INTEGER;
|
|
|
|
RETURN HOST.FileWrite(F, Buffer, bytes)
|
|
|
|
END FileWrite;
|
2016-10-24 02:30:27 +03:00
|
|
|
|
|
|
|
|
2019-03-11 11:59:55 +03:00
|
|
|
PROCEDURE FileCreate* (FName: ARRAY OF CHAR): INTEGER;
|
|
|
|
RETURN HOST.FileCreate(FName)
|
|
|
|
END FileCreate;
|
2016-10-24 02:30:27 +03:00
|
|
|
|
|
|
|
|
2019-03-11 11:59:55 +03:00
|
|
|
PROCEDURE FileClose* (F: INTEGER);
|
2016-10-24 02:30:27 +03:00
|
|
|
BEGIN
|
2019-03-11 11:59:55 +03:00
|
|
|
HOST.FileClose(F)
|
|
|
|
END FileClose;
|
2016-10-24 02:30:27 +03:00
|
|
|
|
|
|
|
|
2019-03-11 11:59:55 +03:00
|
|
|
PROCEDURE FileOpen* (FName: ARRAY OF CHAR): INTEGER;
|
|
|
|
RETURN HOST.FileOpen(FName)
|
|
|
|
END FileOpen;
|
2016-10-24 02:30:27 +03:00
|
|
|
|
|
|
|
|
2019-03-11 11:59:55 +03:00
|
|
|
PROCEDURE GetArg* (i: INTEGER; VAR str: ARRAY OF CHAR);
|
2016-10-24 02:30:27 +03:00
|
|
|
BEGIN
|
2019-03-11 11:59:55 +03:00
|
|
|
HOST.GetArg(i, str)
|
|
|
|
END GetArg;
|
2016-10-24 02:30:27 +03:00
|
|
|
|
|
|
|
|
2019-03-11 11:59:55 +03:00
|
|
|
PROCEDURE Exit* (code: INTEGER);
|
2016-10-24 02:30:27 +03:00
|
|
|
BEGIN
|
2019-03-11 11:59:55 +03:00
|
|
|
HOST.ExitProcess(code)
|
|
|
|
END Exit;
|
2016-10-24 02:30:27 +03:00
|
|
|
|
|
|
|
|
2019-03-11 11:59:55 +03:00
|
|
|
PROCEDURE GetTickCount* (): INTEGER;
|
|
|
|
RETURN HOST.GetTickCount()
|
|
|
|
END GetTickCount;
|
2016-10-24 02:30:27 +03:00
|
|
|
|
2019-03-11 11:59:55 +03:00
|
|
|
|
|
|
|
PROCEDURE OutChar* (c: CHAR);
|
2016-10-24 02:30:27 +03:00
|
|
|
BEGIN
|
2019-03-11 11:59:55 +03:00
|
|
|
HOST.OutChar(c)
|
|
|
|
END OutChar;
|
2016-10-24 02:30:27 +03:00
|
|
|
|
|
|
|
|
2019-03-11 11:59:55 +03:00
|
|
|
PROCEDURE splitf* (x: REAL; VAR a, b: INTEGER): INTEGER;
|
|
|
|
RETURN HOST.splitf(x, a, b)
|
|
|
|
END splitf;
|
2016-10-24 02:30:27 +03:00
|
|
|
|
|
|
|
|
2019-03-11 11:59:55 +03:00
|
|
|
PROCEDURE isRelative* (path: ARRAY OF CHAR): BOOLEAN;
|
|
|
|
RETURN HOST.isRelative(path)
|
|
|
|
END isRelative;
|
2016-10-24 02:30:27 +03:00
|
|
|
|
|
|
|
|
2019-03-11 11:59:55 +03:00
|
|
|
PROCEDURE GetCurrentDirectory* (VAR path: ARRAY OF CHAR);
|
|
|
|
BEGIN
|
|
|
|
HOST.GetCurrentDirectory(path)
|
|
|
|
END GetCurrentDirectory;
|
2016-10-24 02:30:27 +03:00
|
|
|
|
|
|
|
|
2019-03-11 11:59:55 +03:00
|
|
|
PROCEDURE UnixTime* (): INTEGER;
|
|
|
|
VAR
|
|
|
|
year, month, day, hour, min, sec: INTEGER;
|
|
|
|
res: INTEGER;
|
2016-10-24 02:30:27 +03:00
|
|
|
|
|
|
|
BEGIN
|
2019-03-11 11:59:55 +03:00
|
|
|
IF OS = "LINUX" THEN
|
|
|
|
res := HOST.UnixTime()
|
|
|
|
ELSE
|
|
|
|
HOST.now(year, month, day, hour, min, sec);
|
|
|
|
res := UNIXTIME.time(year, month, day, hour, min, sec)
|
|
|
|
END
|
|
|
|
|
|
|
|
RETURN res
|
|
|
|
END UnixTime;
|
|
|
|
|
2016-10-24 02:30:27 +03:00
|
|
|
|
|
|
|
BEGIN
|
2019-03-11 11:59:55 +03:00
|
|
|
time := GetTickCount();
|
|
|
|
COPY(HOST.eol, eol);
|
|
|
|
maxreal := 1.9;
|
|
|
|
PACK(maxreal, 1023)
|
2016-10-24 02:30:27 +03:00
|
|
|
END UTILS.
|