All your code is wrapped in a with sourcequery do begin
block, so any identifier within that block is first checked for whether it could be a member of sourcequery
. That variable, evidently, has a member named eof
that isn't a function. The compiler binds the eof
name to that non-function instead of the function you expected it to be bound to, and therefore complains when you attempt to use it like a function.
The best solution is to stop using with
. It leads to problems like this, where the apparent scope of names doesn't match the one the compiler sees. It also leads to problems debugging (because of a long-standing bug in the debugger, where it interprets names the way you did here, rather than the way the compiler interprets them). It can lead to other bugs, too. If you don't like typing sourcequery.xyz
all the time, then you can create an alias for sourcequery
that doesn't take up so much room:
var
sq: TypeOfSourceQuery;
begin
sq := sourcequery;
sq.Close;
sq.SQL.Clear;
...
If you really don't want to use that solution, then you can use the quick-and-easy solution, which is to qualify the eof
name with the unit it belongs to. In your case, you want the function defined in the System unit, so change your code to indicate that:
while not System.Eof(s1) do begin