100大分解决一个小问题!!!大家快来看看!!!(100分)

  • 主题发起人 主题发起人 dinny
  • 开始时间 开始时间
D

dinny

Unregistered / Unconfirmed
GUEST, unregistred user!
我的程序在编译时,光标始终停在while not Eof(F) do begin的“(”前,
出现的错误为:
Missing operator or semicolon
程序其他的地方没有任何错误,如去掉这部分代码,可编译通过,这是怎么回事呢?
 
while not Eof do begin
 
to QuickSilver:
那怎么表示是哪个文件呢?
 
怎么可能呢?
你看看帮助里的例子:

var

F1, F2: TextFile;
Ch: Char;
begin
if OpenDialog1.Execute then begin
AssignFile(F1, OpenDialog1.Filename);
Reset(F1);
if SaveDialog1.Execute then begin
AssignFile(F2, SaveDialog1.Filename);
Rewrite(F2);
while not Eof(F1) do
begin
Read(F1, Ch);
Write(F2, Ch);
end;
CloseFile(F2);
end;
CloseFile(F1);
end;

end;
 
这个没有问题。
var

F1, F2: TextFile;
Ch: Char;
begin
if OpenDialog1.Execute then begin
AssignFile(F1, OpenDialog1.Filename);
Reset(F1);
if SaveDialog1.Execute then begin
AssignFile(F2, SaveDialog1.Filename);
Rewrite(F2);
while not Eof(F1) do
begin
Read(F1, Ch);
Write(F2, Ch);
end;
CloseFile(F2);
end;
CloseFile(F1);
end;
 
就是就是,Eof是应该带参数的
 
但是我的程序就是编译不通过,怎么回事呀?
 
是我搞错了,你出错之前的代码贴一些出来
 
是不是有了中文的括号啊!呵呵
 
我没有用中文括号,前面的代码非常多,但是去掉出错的部分其他部分可编译通过。
ap:=TStringlist.Create;
Session.GetAliasNames(ap); {È¡µÃ±ðÃûÁбí}
if (ap.IndexOf(Style+'rslt') = -1) then begin { ±ðÃû²»´æÔÚ }
{ ½¨Á¢±ðÃû }
AParams := TStringList.Create;
Session.GetAliasParams('Aro',AParams);
dir := Copy(AParams.Strings[0],6,255)+'/'+Style;
// dirbak := GetCurrentDir;
// {$I-}
// ChDir(dir);
// if IOResult <> 0 then
// MkDir(dir);
// ChDir(dirbak);
MkDir(dir+'/'+'rslt');
Session.AddStandardAlias(Style+'rslt',dir+'/rslt','Paradox');
Session.SaveConfigFile;

{ ½¨Á¢Êý¾Ý±íresult.db }
with Table1 do begin
Active := False;
DatabaseName := Style+'rslt';
TableType := ttParadox;
TableName := 'result.db';

with FieldDefs do begin
Clear;
with AddFieldDef do begin
Name := '»úÃôÐÔ´úÂë';
DataType := ftInteger;
end;
with AddFieldDef do begin
Name := '³õʼ¸ß¶È';
DataType := ftFloat;
end;
with AddFieldDef do begin
Name := '³õʼÂíºÕÊý';
DataType := ftFloat;
end;
with AddFieldDef do begin
Name := 'Ó°Ïì²ÎÊýÖµ';
DataType := ftFloat;
end;
with AddFieldDef do begin
Name := '½á¹û²ÎÊý1';
DataType := ftFloat;
end;
with AddFieldDef do begin
Name := '½á¹û²ÎÊý2';
DataType := ftFloat;
end;
with AddFieldDef do begin
Name := 'Êý¾Ý±íÃû';
DataType := ftString;
Size := 15;
end;
with AddFieldDef do begin
Name := 'Ó°Ïì²ÎÊýÃû';
DataType := ftString;
Size := 4;
end;
end;
CreateTable;
end;
end;

{ ¶ÁÊý¾ÝÎļþresult_1.datÈë¿â£¬×÷Ϊ½á¹û²ÎÊý1¡¢2ÖеÄÖµ }

with Query1 do begin
Close;
SQL.Clear;
SQL.Add(Format('Select * from result.db where »úÃôÐÔ´úÂë=%d and ³õʼ¸ß¶È=%f and ³õʼÂíºÕÊý=%f',[Jmxdm,Height,mah]));
Open;
if Fields[0].AsString <> '' then begin { ½á¹ûÒÑ´æÔÚ }
if MessageDlg('½á¹ûÒÑ´æÔÚ£¬ÊÇ·ñ¸²¸Ç£¿',mtInformation,[mbYes,mbNO],0)=mrNo then begin
Exit; { ²»¸²¸Ç£¬Í˳ö }
end
else begin
{ ¸²¸ÇÒÑ´æÔÚÊý¾Ý }
Edit;
FieldValues['Ó°Ïì²ÎÊýÖµ'] := StrToFloat(Edit1.Text);
FieldValues['Ó°Ïì²ÎÊýÃû'] := IEComboBox1.Text;
datafilename := Fields[6].AsString;
AssignFile(F, GetCurrentDir+'/datafile/'+'result_2.txt');
Reset(F);
Read(F,data);
FieldValues['½á¹û²ÎÊý1'] := data;
Read(f,data);
FieldValues['½á¹û²ÎÊý2'] := data;
Post;
CloseFile(F);
end;
end
else begin
{ ½á¹û²»´æÔÚ£¬Èë¿â }
with Table1 do begin
Active := False;
DataBaseName := Style+'rslt';
TableType := ttParadox;
TableName := 'result.db';
Active := True;
Edit;
Append;
FieldValues['»úÃôÐÔ´úÂë'] := Jmxdm;
FieldValues['³õʼ¸ß¶È'] := Height;
FieldValues['³õʼÂíºÕÊý'] := mah;
FieldValues['Ó°Ïì²ÎÊýÖµ'] := StrToFloat(Edit1.Text);
FieldValues['Ó°Ïì²ÎÊýÃû'] := IEComboBox1.Text;
FieldValues['Êý¾Ý±íÃû'] := Format('t%d.db',[Recordcount]);
datafilename := Format('t%d.db',[Recordcount]);
AssignFile(F, GetCurrentDir+'/datafile/'+'result_2.txt');
Reset(F);
Read(F,data);
FieldValues['½á¹û²ÎÊý1'] := data;
Read(f,data);
FieldValues['½á¹û²ÎÊý2'] := data;
Post;
CloseFile(F);
end;
end;
end;

{ ¶ÁÊý¾ÝÎļþresult_2.datÈë¿â£¬×÷ΪÊý¾Ý±íµÄ¼Ç¼ÄÚÈÝ }

with Table1 do begin
Active := False;
DatabaseName := Style+'rslt';
TableType := ttParadox;
TableName := datafilename;

AssignFile(F, GetCurrentDir+'/datafile/'+'result_1.dat');
Reset(F);
Readln(F,str);
{ ½¨Á¢±í½á¹¹ }
with FieldDefs do begin
Clear;
i := 1;
for j := 1 to 10 do begin
fieldn := '';
c := str;
while (c = ' ') or (c = #9) do begin
i := i+1;
c := str;
end;
while (c > 'A') and (c < 'Z') do begin
fieldn := fieldn + c;
i := i+1;
// c := str;
end;
with AddFieldDef do begin
Name := fieldn;
DataType := ftFloat;
end;
end;
end;
CreateTable;
{ ¼ÓÈëÊý¾Ý }
Active := True;
while not Eof(F) do begin
Edit;
Append;
for j := 1 to 10 do begin
Read(F,data);
FieldValues[Fields[i-1].FieldName] := data;
end;
Post;
Readln(F);
end;
CloseFile(F);
end;
 
copy文件用文件流不就解决了吗
用不着这么麻烦
var TF1,TF2:TFilestream;
begin
try
TF1 := TFileStream.Create('c:/abc.txt',fmopenread);
TF2 := TFileStream.Create('c:/def.txt',fmOpenReadWrite);
TF2.CopyFrom(TF1,TF1.Size);
finally
TF1.free;
TF2.free;
end;
end;
 
多人接受答案了。
 
后退
顶部