You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

107 lines
2.1 KiB
Plaintext

6 years ago
{ Julius Riegel, 20.12.18 }
unit utils;
interface
6 years ago
6 years ago
uses
crt,
Graph;
6 years ago
6 years ago
type
person = record
6 years ago
pname: string[10];
psurname: string[10];
number: integer;
6 years ago
end;
6 years ago
function int_to_str(i: integer): string;
procedure write_file(fname: string; data: person);
function read_file(fname: string): person;
procedure drawrectnums(nums: array of integer; size: integer);
6 years ago
procedure init_graphics;
6 years ago
procedure graphictext(x, y, size: integer; text: string);
6 years ago
implementation
6 years ago
function int_to_str(i: integer): string;
6 years ago
begin
Str(i, int_to_str);
end;
6 years ago
procedure write_file(fname: string; data: person);
6 years ago
var
6 years ago
outfile: file of person;
6 years ago
begin
Assign(outfile, fname);
Rewrite(outfile);
Write(outfile, data);
Close(outfile);
end;
6 years ago
function read_file(fname: string): person;
6 years ago
var
6 years ago
infile: file of person;
6 years ago
begin
Assign(infile, fname);
Reset(infile);
Read(infile, read_file);
Close(infile);
end;
6 years ago
function format_num(num: integer): string;
6 years ago
var
6 years ago
tempstr: string;
6 years ago
begin
tempstr := int_to_str(num);
if (tempstr = '0') then
tempstr := '*';
format_num := tempstr;
end;
procedure init_graphics;
var
gdriver,
6 years ago
gmode: integer;
6 years ago
begin
DetectGraph(gdriver, gmode);
InitGraph(gdriver, gmode, '');
end;
6 years ago
procedure graphictext(x, y, size: integer; text: string);
6 years ago
begin
6 years ago
SetTextStyle(0, 0, round(size / 40));
6 years ago
OutTextXY(x, y, text);
end;
6 years ago
procedure drawrectnums(nums: array of integer; size: integer);
6 years ago
var
xsize,
ysize,
xstart,
6 years ago
ystart: integer;
6 years ago
begin
xsize := GetMaxX;
ysize := GetMaxY;
6 years ago
xstart := Round(xsize / 2) - round(size / 2);
ystart := Round(ysize / 2) - round(size / 2);
SetTextStyle(0, 0, round(size / 40));
OutTextXY(xstart + size, ystart, format_num(nums[0]));
OutTextXY(xstart + size, ystart + size, format_num(nums[1]));
OutTextXY(xstart, ystart + size, format_num(nums[2]));
6 years ago
OutTextXY(xstart, ystart, format_num(nums[3]));
end;
6 years ago
procedure draw_lines(xstart, ystart, size: integer);
6 years ago
begin
6 years ago
Line(xstart, ystart, xstart + size, ystart);
Line(xstart + size, ystart, xstart + size, ystart + size);
Line(xstart + size, ystart + size, xstart, ystart + size);
Line(xstart, ystart + size, xstart, ystart);
6 years ago
end;
begin
6 years ago
{ Main Body }
6 years ago
end.