From dcecce0fbafc11c2d2e1a8d1d1ca5956d9c026cd Mon Sep 17 00:00:00 2001 From: Trivernis Date: Thu, 20 Dec 2018 14:29:32 +0100 Subject: [PATCH] Reformatted code --- praxistest/lib/utils.pas | 66 +++++++++++++++++++++------------------- praxistest/programm1.pas | 10 +++--- praxistest/programm2.pas | 22 +++++++------- 3 files changed, 49 insertions(+), 49 deletions(-) diff --git a/praxistest/lib/utils.pas b/praxistest/lib/utils.pas index b2d9cbf..7415a77 100644 --- a/praxistest/lib/utils.pas +++ b/praxistest/lib/utils.pas @@ -3,33 +3,35 @@ unit utils; interface + uses crt, Graph; + type person = record - pname : String[10]; - psurname : String[10]; - number: Integer; + pname: string[10]; + psurname: string[10]; + number: integer; end; -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); +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); procedure init_graphics; -procedure graphictext(x, y, size: Integer; text: String); +procedure graphictext(x, y, size: integer; text: string); implementation -function int_to_str(i: Integer): String; +function int_to_str(i: integer): string; begin Str(i, int_to_str); end; -procedure write_file(fname: String; data: person); +procedure write_file(fname: string; data: person); var - outfile: File of person; + outfile: file of person; begin Assign(outfile, fname); @@ -38,9 +40,9 @@ begin Close(outfile); end; -function read_file(fname: String): person; +function read_file(fname: string): person; var - infile: File of person; + infile: file of person; begin Assign(infile, fname); Reset(infile); @@ -48,9 +50,9 @@ begin Close(infile); end; -function format_num(num: Integer) : String; +function format_num(num: integer): string; var - tempstr: String; + tempstr: string; begin tempstr := int_to_str(num); if (tempstr = '0') then @@ -61,45 +63,45 @@ end; procedure init_graphics; var gdriver, - gmode : Integer; + gmode: integer; begin DetectGraph(gdriver, gmode); InitGraph(gdriver, gmode, ''); end; -procedure graphictext(x, y, size : Integer; text: String); +procedure graphictext(x, y, size: integer; text: string); begin - SetTextStyle(0, 0, round(size/40)); + SetTextStyle(0, 0, round(size / 40)); OutTextXY(x, y, text); end; -procedure drawrectnums(nums: Array of Integer; size: Integer); +procedure drawrectnums(nums: array of integer; size: integer); var xsize, ysize, xstart, - ystart: Integer; + ystart: integer; begin xsize := GetMaxX; ysize := GetMaxY; - 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])); + 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])); OutTextXY(xstart, ystart, format_num(nums[3])); end; -procedure draw_lines(xstart, ystart, size: Integer); +procedure draw_lines(xstart, ystart, size: integer); begin - 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); + 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); end; begin - { Main Body } + { Main Body } end. \ No newline at end of file diff --git a/praxistest/programm1.pas b/praxistest/programm1.pas index 58fee8b..a37195a 100644 --- a/praxistest/programm1.pas +++ b/praxistest/programm1.pas @@ -6,12 +6,12 @@ uses utils in './lib/utils.pas'; const - fname = './persons/Name'; +fname = './persons/Name'; -procedure gen_entry(fnum: Integer); +procedure gen_entry(fnum: integer); var temp_person: person; - curr_fname : String; + curr_fname: string; begin curr_fname := fname + int_to_str(fnum) + '.prs'; Write(' Name: '); @@ -25,14 +25,12 @@ begin end; var - i : Integer; + i: integer; begin Randomize; WriteLn; for i := 1 to 4 do - begin gen_entry(i); - end; WriteLn('[+] All names saved.'); end. \ No newline at end of file diff --git a/praxistest/programm2.pas b/praxistest/programm2.pas index 1a565bf..93945e5 100644 --- a/praxistest/programm2.pas +++ b/praxistest/programm2.pas @@ -5,25 +5,25 @@ program programm2; uses utils in './lib/utils.pas'; -const - fname = './persons/Name'; +const +fname = './persons/Name'; -function reading_file_int(fnum: Integer): Integer; +function reading_file_int(fnum: integer): integer; var - curr_fname: String; + curr_fname: string; temp_entry: person; begin curr_fname := fname + int_to_str(fnum) + '.prs'; temp_entry := read_file(curr_fname); - graphictext(10, 20*fnum, 80, 'file' + int_to_str(fnum) + ': ' + curr_fname); - reading_file_int := temp_entry.number; + graphictext(10, 20 * fnum, 80, 'file' + int_to_str(fnum) + ': ' + curr_fname); + reading_file_int := temp_entry.number; end; var - i: Integer; - numsum, num: Integer; - nums: Array [0..3] of Integer; + i: integer; + numsum, num: integer; + nums: array [0..3] of integer; begin WriteLn; @@ -32,10 +32,10 @@ begin for i := 1 to 4 do begin num := reading_file_int(i); - nums[i-1] := num; + nums[i - 1] := num; numsum := numsum + num; end; - graphictext(10, 100, 80, ('sum: '+ int_to_str(numsum))); + graphictext(10, 100, 80, ('sum: ' + int_to_str(numsum))); drawrectnums(nums, 80); ReadLn; end. \ No newline at end of file