unit
USPS;
interface
uses
Windows, Messages, SysUtils, Classes, Forms;
type
TspsStroka=
class
Npr, Npk, X, Y:
Real
;
constructor
create();
procedure
read(str:
string
);
end
;
TSPS=
class
name:
string
;
SpsStrokaCount:
Cardinal
;
SizeOfmas:
Cardinal
;
spsStroki:
array
of
TspsStroka;
constructor
create(openname:
string
);
procedure
read(
openname:
string
);
procedure
writetofile(savename:
string
);
end
;
implementation
constructor
TspsStroka
.
create();
begin
Npr:=
0
;
Npk:=
0
;
X:=
0
;
Y:=
0
;
end
;
constructor
TSPS
.
create(openname:
string
);
var
t:TStringList;
i:
Integer
;
str:
string
;
begin
name:=openname;
SpsStrokaCount:=
0
;
t:=TStringList
.
Create;
t
.
LoadFromFile(openname);
SizeOfmas:=
0
;
for
i:=
0
to
t
.
Count-
1
do
begin
Application
.
ProcessMessages();
str:=t[i];
if
str[
1
]=
'H'
then
Continue;
inc(SizeOfmas);
end
;
SetLength(spsStroki,SizeOfmas);
t
.
Free;
end
;
procedure
TspsStroka
.
read(str:
string
);
begin
Npr:=strtofloat(copy(str,
2
,
16
));
Npk:=strtofloat(copy(str,
18
,
8
));
X:=strtofloat(copy(str,
47
,
9
));
Y:=strtofloat(copy(str,
56
,
10
));
end
;
procedure
tsps
.
read(
openname:
string
);
var
i:
Cardinal
;
str:
string
;
t:TStringList;
begin
t:=TStringList
.
Create;
t
.
LoadFromFile(openname);
for
i:=
0
to
t
.
Count-
1
do
begin
Application
.
ProcessMessages();
str:=t[i];
if
str[
1
]=
'H'
then
Continue;
spsStroki[SpsStrokaCount]:=TspsStroka
.
create();
spsStroki[SpsStrokaCount].read(str);
Inc(SpsStrokaCount);
end
;
t
.
Free;
end
;
procedure
TSPS
.
writetofile(savename:
string
);
var
ft:TStringList;
i:
Integer
;
str:
string
;
begin
ft:=TStringList
.
Create;
for
i:=
0
to
SizeOfmas-
1
do
begin
Application
.
ProcessMessages();
str:=floatToStr(spsStroki[i].Npr)+#
9
+floatToStr(spsStroki[i].Npk)+#
9
+floatToStr(spsStroki[i].X)+#
9
+floatToStr(spsStroki[i].Y);
ft
.
Add(str);
str:=
''
;
end
;
ft
.
SaveToFile(savename);
ft
.
Free;
end
;
end
.