Форум программистов
 

Восстановите пароль или Зарегистрируйтесь на форуме, о проблемах и с заказом рекламы пишите сюда - alarforum@yandex.ru, проверяйте папку спам!

Вернуться   Форум программистов > IT форум > Помощь студентам
Регистрация

Восстановить пароль

Купить рекламу на форуме - 42 тыс руб за месяц

Ответ
 
Опции темы Поиск в этой теме
Старый 31.05.2011, 22:27   #1
илья001
Пользователь
 
Регистрация: 18.05.2011
Сообщений: 21
По умолчанию Ошибка при компиляции Подкорректировать код DELPHI

вроде все устраивает кроме трех последних кнопок помогите сделать так что бы я мог сохранить все в текстовом файле, просто сохранить что бы я мог это открыть потом в проге (на кнопку загрузить) Пожалуйста с комментариями я очень слаб в программировании))))
Код:
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'
Изображения
Тип файла: jpg форум.jpg (29.1 Кб, 56 просмотров)
илья001 вне форума Ответить с цитированием
Старый 31.05.2011, 22:31   #2
илья001
Пользователь
 
Регистрация: 18.05.2011
Сообщений: 21
По умолчанию

вроде все устраивает кроме трех последних кнопок

Код:
procedure TForm1.Button4Click(Sender: TObject);

   var
f:File of TInform;
    i:integer;
begin
 SaveDialog1.Execute;
AssignFile(f,SaveDialog1.FileName);
Rewrite(f);
for i:=0 to Num-1 do
     Write(f,inf[i]);
CloseFile(f);
end;



procedure TForm1.Button5Click(Sender: TObject);

  var F1:TextFile;
i:integer;
begin
SaveDialog2.Execute;
AssignFile(f1,Savedialog2.Filename);
Rewrite(f1);
for i:=0 to Num-1 do
begin
 writeln(f1,'êîëè÷åñòâî çàïèñåé ',i+1,' : ');
 writeln(f1,'Íàèìåíîâàíèå : ',inf[i].Name,' # ');
 writeln(f1,' òèï ýêðàíà   : ',inf[i].Typescreen,' # ');
  writeln(f1,'  ðàçðåøåíèå ýêðàíà  : ',inf[i].ovewierscreen,' # ');
 writeln(f1,'Öâåò êîðïóñà  : ',inf[i].Color,' # ');
 writeln(f1,'bluetooth  : ',inf[i].bluetooth,' # ');
  writeln(f1,' WiFi : ',inf[i].wifi,' # ');
    writeln(f1,'Êàìåðà (mega pixels) : ',inf[i].camera,' # ');
       writeln(f1,'Öåíà : ',inf[i]. cena,' # ');
 writeln(f1);
end;
CloseFile(f1);
end;


procedure TForm1.Button6Click(Sender: TObject);

   var F:file of Tphone;
    l,k,i:integer;
begin
 if OpenDialog1.Execute then   begin
  ListBox1.Clear;
  for i:=0 to 4 do
  StringGrid1.Cells[1,i]:='';
  AssignFile(f,OpenDialog1.FileName);
  Reset(f);
  l:=0;
  while not Eof(f)  do
    begin
      Read(f,inf[l]);
      listbox1.Items.Add(inf[l-1].Name);
      inc(l);
    end;
    CloseFile(f);
 end;
 end;


end.
вот и они
илья001 вне форума Ответить с цитированием
Ответ


Купить рекламу на форуме - 42 тыс руб за месяц



Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Код в СИ (ошибка при компиляции) Ислам Помощь студентам 4 27.02.2011 21:50
Ошибка при компиляции Banner Помощь студентам 2 20.02.2011 13:09
Ошибка при компиляции (Delphi) alxd Помощь студентам 6 24.07.2009 13:03
Ошибка при компиляции CrazyRabbit Общие вопросы C/C++ 3 25.12.2008 18:41
Ошибка при компиляции MasterofCDM Общие вопросы Delphi 2 11.11.2008 09:35