I have a problem with some simple code I simply cannot resolve. I'm using Delphi 5 with all updates applied.
I have this code block:
procedure TForm1.LoadBtnClick(Sender: TObject);
var
s1, s2, s3 : Textfile;
sa, sb, RString, SQLString : string;
begin
with sourcequery do begin
Close;
SQL.Clear;
SQL.Add('delete * from source');
ExecSQL;
Close;
AssignFile(S2, 'c:delphi programseventssource1.txt');
AssignFile(S1, 'c:delphi programseventssource2.txt');
Reset(s2);
Reset(s1);
while not eof(s1) do begin
readln(s1, RString);
SQLString := 'insert into source1(f1, f2) values(';
SQLstring := SQLString+ QuotedStr(copy(Rstring, 1, pos(chr(9), Rstring)-1))+', ';
SQLString := SQLString+QuotedStr(copy(Rstring, pos(chr(9),Rstring)+1,length(Rstring)))+')';
with sourcequery do begin
close;
SQL.Clear;
SQL.Add(SQLString);
ExecSQL;
end;
end;
end;
end;
When I try to compile it, though, it halts after "eof(" on this line:
while not eof(s1) do begin
with the "missing operator or semi-colon" error message.
Try as I might I can find no error - missing operators OR semi-colons. I have commented the file-reading block out and it compiles fine. I've retyped it a number of times in case there were hidden special characters. So far this is the entire program apart from the header information.
Can anyone spot the silly error?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…