вроде все устраивает кроме трех последних кнопок помогите сделать так что бы я мог сохранить все в текстовом файле, просто сохранить что бы я мог это открыть потом в проге (на кнопку загрузить) Пожалуйста с комментариями я очень слаб в программировании))))
Код:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
ListBox1: TListBox;
StringGrid1: TStringGrid;
Label1: TLabel;
Button4: TButton;
Button5: TButton;
Button6: TButton;
SaveDialog1: TSaveDialog;
SaveDialog2: TSaveDialog;
OpenDialog1: TOpenDialog;
procedure FormCreate(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure ListBox1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
type
TPhone=record
Name:string[30];
Typescreen:string[30];
ovewierscreen:string[15];
Color:string[20];
bluetooth:string[6];
wifi:string[6];
camera:string[10];
cena:string[10];
end;
type
TInform=array [0..35] of TPhone;
var
Inf:TInform;
num,n,i:integer;
SG:TStringGrid;
f1: Textfile;
f:file of Tphone;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
ListBox1.Items.Add('');
Label1.Caption := 'Âñåãî: 0';
StringGrid1.Cells [0,0] := 'Íàèìåíîâàíèå';
StringGrid1.Cells [0,1] := 'òèï ýêðàíà';
StringGrid1.Cells [0,2] := 'ðàçðåøåíèå ýêðàíà';
StringGrid1.Cells [0,3] := 'Öâåò êîðïóñà';
StringGrid1.Cells [0,4] := 'bluetooth';
StringGrid1.Cells [0,5] := 'WiFi';
StringGrid1.Cells [0,6] := 'Êàìåðà (mega pixels)';
StringGrid1.Cells [0,7] := 'Öåíà';
ListBox1.ItemIndex := 0;
end;
procedure TForm1.Button2Click(Sender: TObject);
var num, i,k, n: integer;
begin
num :=ListBox1.ItemIndex;
n :=ListBox1.count-1;
with Inf[Num] do
begin
Name:=StringGrid1.Cells[1,0];
Typescreen:=StringGrid1.Cells[1,1];
ovewierscreen:=StringGrid1.Cells[1,2];
Color:=StringGrid1.Cells[1,3];
bluetooth:=StringGrid1.Cells[1,4];
wifi:= StringGrid1.Cells[1,5];
camera:= StringGrid1.Cells[1,6];
cena:= StringGrid1.Cells[1,7];
end;
ListBox1.Items.Clear;
for i:=0 to n do
ListBox1.Items.Add(Inf[i].Name);
ListBox1.Items.Add('');
ListBox1.ItemIndex:=ListBox1.Items.Count-1;
inc(i);
Label1.Caption := 'Êîëè÷åñâòî çàïèñåé: '+IntToStr(Num+1);
end;
procedure TForm1.ListBox1Click(Sender: TObject);
var
n: integer;
begin
n:=ListBox1.ItemIndex;
StringGrid1.Cells[1,0]:=Inf[n].Name;
StringGrid1.Cells[1,1]:=Inf[n].Typescreen;
StringGrid1.Cells[1,2]:=Inf[n].ovewierscreen;
StringGrid1.Cells[1,3]:=Inf[n].Color;
StringGrid1.Cells[1,4]:=Inf[n].bluetooth;
StringGrid1.Cells[1,5]:=Inf[n].wifi;
StringGrid1.Cells[1,6]:=Inf[n].camera;
StringGrid1.Cells[1,7]:=Inf[n].cena;
if n=ListBox1.Count - 1 then
begin
StringGrid1.Cells[1,0]:='';
StringGrid1.Cells[1,1]:='';
StringGrid1.Cells[1,2]:='';
StringGrid1.Cells[1,3]:='';
StringGrid1.Cells[1,4]:='';
StringGrid1.Cells[1,5]:='';
StringGrid1.Cells[1,6]:='';
StringGrid1.Cells[1,7]:='';
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
var num, i, n: integer;
begin
num :=ListBox1.ItemIndex;
n :=ListBox1.count-1;
with Inf[Num] do
begin
Name:=StringGrid1.Cells[1,0];
Typescreen:=StringGrid1.Cells[1,1];
ovewierscreen:=StringGrid1.Cells[1,2];
Color:=StringGrid1.Cells[1,3];
bluetooth:=StrinGgrid1.Cells[1,4];
wifi:= Stringgrid1.Cells[1,5];
camera:= StringGrid1.Cells[1,6];
cena:= StringGrid1.Cells[1,7];
ListBox1.Items.Clear;
for i:=0 to n do
ListBox1.Items.Add(Inf[i].Name);
ListBox1.ItemIndex:=ListBox1.Items.Count-1;
inc(i);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
n, i, num: integer;
begin
if Application.MessageBox('Óäàëèòü çàïèñü?','lab7',MB_OKCANCEL)=ID_CANCEL then exit;
n:=ListBox1.ItemIndex;
num := ListBox1.count-1;
if n>=0 then
begin
for i:=n to Num-2 do
Inf[i]:=Inf[i+1];
ListBox1.Items.Delete(n);
dec(Num);
Label1.Caption:='Âñåãî : '+IntToStr(Num);
ListBox1.ItemIndex:=-1;
end;
end;
ошибка в Write(f,inf[i]);
[Error] Unit1.pas(227): Incompatible types: 'TInform' and 'TPhone'