unit
Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids;
type
TForm2 =
class
(TForm)
Label1: TLabel;
StringGrid1: TStringGrid;
Button1: TButton;
procedure
Form2Activate(Sender: TObject);
procedure
Button1Click(Sender: TObject);
private
public
end
;
var
Form2: TForm2;
implementation
{$R *.dfm}
uses
Unit1, Unit3, Unit4, Unit5;
procedure
TForm2
.
Form2Activate(Sender: TObject);
var
fv1:TextFile;
s,s1,s2,s3,s4:
string
[
255
];
s5:
string
[
2
];
i,k:
integer
;
begin
StringGrid1
.
Cells[
0
,
0
]:=
'Цех'
;
StringGrid1
.
Cells[
1
,
0
]:=
'Наименование изделия'
;
StringGrid1
.
Cells[
2
,
0
]:=
'Наименование детали'
;
StringGrid1
.
Cells[
3
,
0
]:=
'Количество деталей, шт.'
;
AssignFile(fv1,
'Изделия.txt'
);
if
not
(FileExists(
'Изделия.txt'
))
then
ShowMessage(
'Файла с указанным именем не сущетсвует'
)
else
begin
Reset(fv1);
Readln(fv1,s);
i:=-
1
;
while
not
(SeekEof(fv1))
do
begin
i:=i+
1
;
Str(i:
2
,s5);
Readln(fv1,s);
k:=Pos(Chr(
$09
),s);
if
k=
0
then
ShowMessage(
'Строка №'
+s5+
' содержит ошибку'
)
else
begin
s2:=Copy(s,
1
,k-
1
);
Delete(s,
1
,k);
k:=Pos(Chr(
$09
),s);
if
(k=
0
)
or
(s1=
''
)
then
ShowMessage(
'Строка №'
+s5+
'содержит ошибку'
)
else
begin
s3:=Copy(s,
1
,k-
1
);
Delete(s,
1
,k);
k:=Pos(Chr(
$09
),s);
if
(k=
0
)
or
(s3=
''
)
then
ShowMessage(
'Строка №'
+s5+
'содержит ошибку'
)
else
begin
s4:=Copy(s,
1
,k-
1
);
Delete(s,
1
,k);
k:=Pos(Chr(
$09
),s);
if
(s3=
''
)
then
ShowMessage(
'Строка №'
+s5+
'содержит ошибку'
)
else
begin
ceh[i]:=s1;
StringGrid1
.
Cells[
0
,i]:=s1;
naim[i]:=s2;
StringGrid1
.
Cells[
1
,i]:=s2;
det[i]:=s3;
StringGrid1
.
Cells[
2
,i]:=s3;
kolich[i]:=StrToFloat(s4);
StringGrid1
.
Cells[
4
,i]:=s4;
end
;
end
;
end
;
end
;
end
;
end
;
n:=i;
CloseFile(fv1);
W1:=
True
;
end
;
procedure
TForm2
.
Button1Click(Sender: TObject);
begin
Close
end
;
end
.