
14.01.2011, 15:42
|
Прохожий
|
|
Регистрация: 14.01.2011
Сообщения: 1
Репутация: 10
|
|
Проблема при попытке чтения файла
Приветствую. Сегодня напоролся на следующую проблему при попытке считать запись с файла выдает ошибку Incompatible types что значит не совместимые типы данных но в чем соль проблемы типы переменных идентичны string[40] и file of string[40]. На всякий случай код:
Код:
unit translators;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TTranslator = class(TForm)
ListBox1: TListBox;
Edit1: TEdit;
Label1: TLabel;
Label2: TLabel;
Edit2: TEdit;
Button1: TButton;
Button2: TButton;
Button3: TButton;
ListBox2: TListBox;
Label3: TLabel;
Button4: TButton;
Button5: TButton;
Edit3: TEdit;
Button6: TButton;
procedure FormCreate(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
type resul = record
nayden:boolean;
position:integer;
perevod:string;
end;
var
Translator: TTranslator;
Origf: file of string[40];
perevodf :file of string[40];
Orig:string[40];
perevod:string[40];
count:integer;
countf :file of integer;
rez:resul;
implementation
uses C_Main ;
{$R *.dfm}
//ïîèñê ïî ñëîâàðþ
function search(poisk:string;origin:boolean):resul;
var i:integer;
per:String;
begin
AssignFile(countf,Translator.ListBox2.Items.Strings[Translator.ListBox2.itemindex]+'_count');
AssignFile(origf, Translator.ListBox2.Items.Strings[Translator.ListBox2.itemindex]+'_orig');
AssignFile(perevodf, Translator.ListBox2.Items.Strings[Translator.ListBox2.itemindex]+'_perevod');
reset(countf);
reset(origf);
reset(perevodf);
read(countf,count);
if origin = true then
begin
for i:=0 to count do
begin
write(origf,orig);
if orig = poisk then
begin
Result.nayden:=true;
FilePos(origf);
Result.position:=FilePos(origf);
Seek(perevodf,FilePos(origf));
read(perevodf,perevod); // Здесь и происходит ошибка
Result.perevod:=perevod;
end;
end;
end
else
begin
for i:=0 to count do
begin
write(perevodf,perevod);
if perevod = poisk then
begin
Result.nayden:=true;
Result.position:=i;
Seek(origf,i);
read(origf,orig);// Здесь происходит таже ошибка
Result.perevod:=perevod;
end;
end;
end;
CloseFile(countf);
CloseFile(origf);
CloseFile(perevodf);
end;
Заранее спасибо
P.S. Сколько раз работал с файлами но такое у меня в первые.
|