-
Notifications
You must be signed in to change notification settings - Fork 2
/
ProgressUnit.pas
66 lines (56 loc) · 1.1 KB
/
ProgressUnit.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
unit ProgressUnit;
// Модуль отображения прогреса в терминале
interface
uses SysUtils;
Procedure InitProgress(Size: Int64);
Procedure SetProgress(Position: Int64);
Var
NoProgress: Boolean;
implementation
const
Long=50;
EmptySection='-';
FillSection='#';
Var
P, S, L, R, Price: Real;
Step: Integer;
Procedure InitProgress(Size: Int64);
Var
i: Word;
Begin
If not NoProgress then
Begin
Step:=Size div 100;
S:=Size;
L:=Long;
Price:=L/S;
WriteLn;
WriteLn;
For i:=1 to Long do
Write(EmptySection);
Write(#13);
End;
End;
Procedure SetProgress(Position: Int64);
Var
pp, i: Word;
Begin
If not NoProgress then
If (Position mod Step)=0 then
Begin
P:=Position;
pp:=Round(Price*P);
For i:=1 to pp do
Write(FillSection);
For i:=1 to Long-pp do
Write(EmptySection);
Write(' ');
R:=(P/S)*100;
pp:=Round(R);
Write(IntToStr(pp)+' % ');
Write(#13);
End;
End;
Begin
NoProgress:=False;
end.