不行啊老兄,我是这样定义的
var
F : textfile;
begin
Assignfile(F,edit1.Text);
reset(F);
seek(f,0);
.....
但当执行到seek(f,0)的时候系统提示
Build
[Error] Unit1.pas(86): Incompatible types
[Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'
请问应该用什么才好
var
f: file of Byte;
size: Longint;
S: string;
y: Integer;
begin
if OpenDialog1.Execute then
begin
AssignFile(f, OpenDialog1.FileName);
Reset(f);
try
size := FileSize(f);
S := 'File size in bytes: ' + IntToStr(size);
y := 10;
Canvas.TextOut(5, y, S);
y := y + Canvas.TextHeight(S) + 5;
S := 'Seeking halfway into file...';
Canvas.TextOut(5, y, S);
y := y + Canvas.TextHeight(S) + 5;
Seek(f, size div 2);
S := 'Position is now ' + IntToStr(FilePos(f));
Canvas.TextOut(5, y, S);
finally
CloseFile(f);
end;
end;
end;
yostgxf 老兄说方法很好,但对于我这样刚入门的初级菜鸟来说还是不会用的,因为我必须得使用readln()函数,对读取的每一个字符串进行搜索分析,日志文件纯文件文件,有哪位前辈能告诉我下面的这种定义方法,怎么才能让文件指针指向文件头部呢?
var
F : textfile;
I : integer;
begin
Assignfile(F,edit1.Text);
reset(F);
FOR I := 1 to 10 do
begin
while not eof(f) do
......
end;
seek(f,0);//这个方法不对,哪位前辈能告诉我这里应该使用什么方法让文件指指针指向文件头呢?
end;
end.