TOpenDialog TSaveDialog , Dialogs . . , Filter . Filter Editor, , , - .
.6.1
OpenDialodI .6.1. *.dat , dat, *.* - ( ).
, .dat DefaultExt -. dat. SaveDialogI ( *.txt).
. . , "" , - "". " "
.6.2
. "" .6.2. , . "Close" . .
Unit Unit1;
Interface
Uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs, Buttons, StdCtrls;
Type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
BitBtn1: TBitBtn;
OpenDialog1: TOpenDialog;
SaveDialog1: TSaveDialog;
Memo1: TMemo;
Procedure FormCreate(Sender: TObject);
Procedure Button1Click(Sender: TObject);
Procedure Button2Click(Sender: TObject);
Procedure Button3Click(Sender: TObject);
Procedure Button4Click(Sender: TObject);
Procedure Button5Click(Sender: TObject);
Procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
Type
TStudent = record
FIO: string[40]; // ...
otc: array[1..3] of word; //
sball: extended; //
end;
var
Fz: file of Tstudent; //
Ft: TextFile; //
Stud: array[1..100] of Tstudent; //
Nzap: integer; //
|
|
FileNameZ, FileNameT: string; //
var
Form1: Tform1;
Implementation
{$R *.DFM}
Procedure TForm1.FormCreate(Sender: TObject);
begin
Edit1.Text:= '';
Edit2.Text:= '';
Edit3.Text:= '';
Edit4.Text:= '';
Memo1.Clear;
Button1.Hide; // " "
Nzap:= 0;
end;
Procedure TForm1.Button1Click(Sender: TObject);
begin
nzap:= nzap + 1;
with stud[nzap] do
begin
FIO:= Edit1.Text;
otc[1]:= StrToInt(Edit2.Text);
otc[2]:= StrToInt(Edit3.Text);
otc[3]:= StrToInt(Edit4.Text);
sball:= (otc[1] + otc[2] + otc[3])/3;
Memo1.Lines.Add(fio + '' + IntToStr(otc[1 ]) +
' ' + IntToStr(otc[2]) + '' + IntToStr(otc[3]));
end;
Write(fz, Stud[nzap]); //
Edit1.Text:= '';
Edit2.Text:= '';
Edit3.Text:= '';
Edit4.Text:= '';
end;
Procedure TForm1.Button2Click(Sender: TObject);
begin
OpenDialog1.Title:= ' ';
//
if OpenDialog1.Execute then
//
begin
FileNameZ:= OpenDialog1.FileName;
//
AssignFile(Fz, FileNameZ);
// Fz
Rewrite(Fz); //
Button1.Show; // " "
end;
end;
Procedure TForm1.Button3Click(Sender: TObject);
begin
if OpenDialog1.Execute then
//
begin
FileNameZ:= OpenDialog1.FileName;
//
AssignFile(Fz, FileNameZ);
// Fz
Reset(Fz); //
end;
While not EOF(fz) do
begin
nzap:= nzap + 1;
Read(fz, stud[nzap]); //
with stud[nzap] do
Memo1.Lines.Add(fio + '' + IntToStr(otc[1]) +
' ' + IntToStr(otc[2]) + '' + IntToStr(otc[3]));
end;
Button1.Show; // " "
end;
Procedure Tform1.Button4Click(Sender: TObject);
//
var
i, j: word;
st: Tstudent;
begin
for i:= 1 to nzap-1 do
for j:= i + 1 to nzap do
if Stud[i].sball < Stud[j].sball then
begin
st:= Stud[i];
Stud[i]:= Stud[j];
Stud[j]:= st;
end;
Memo1.Clear;
for i:= 1 to nzap do
// Memo1
with stud[i] do
Memo1.Lines.Add(IntToStr(i) + '' +
fio + '' + FloatToStrF(sball, fffixed, 4, 2));
end;
Procedure Tform1.Button5Click(Sender: TObject);
//
var
i: word;
begin
if SaveDialog1.Execute then
//
begin
FileNameT:= SaveDialog1.FileName;
//
AssignFile(Ft, FileNameT);
// Ft
Rewrite(Ft); //
end;
for i:=1 to nzap do
with stud[i] do
Writeln(Ft, i:4, '.', fio, sball:8:2);
//
CloseFile(Ft); //
end;
Procedure TForm1.BitBtn1Click(Sender: TObject);
begin
CloseFile(fz);
// "Close"
end;
{
|
|
Procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
CloseFile(fz);
//
end;
}
end.