Board index » delphi » EOF returns true before accessed last record (Delphi 1)

EOF returns true before accessed last record (Delphi 1)

I am using Delphi 1 and am trying to copy all the info from one table
(Cases) to another with identical table (NewCases). The problem (which
is not actually a very big problem it's just a bit worrying) is that
when I use the Next and EOF methods in a while loop the loop finishes
before the last item has been copied, so NewCases ends up with one less
record than Cases.

According to the help file this shouldn't happen. EOF should not be true
until after the Next method has been called while the table was on the
last file. So does anyone know why it is doing this? My code is listed
below.

with NewCases do begin
    Cases.First;
    while not Cases.EOF do begin
        Append;
        for Index:=0 to Cases.FieldCount-1 do
            Fields[Index].AsString:=Cases.Fields[Index].AsString;
            Cases.Next
    end;
end

Thanks in advance for any help,
    Ian
--
Ian Dunn                     I...@polyhedron.com

 

Re:EOF returns true before accessed last record (Delphi 1)


I think your problem may be that you are not explicitly posting the
data. The Next method will post all but the last row; but the last
time it is called, there is no record to go to, so it does nothing.

BTW, wouldn't it be easier to use BatchMove?

HTH,
Dan

On Wed, 23 Feb 2000 16:44:34 +0000, Ian Dunn <I...@polyhedron.com>
wrote:

Quote
>I am using Delphi 1 and am trying to copy all the info from one table
>(Cases) to another with identical table (NewCases). The problem (which
>is not actually a very big problem it's just a bit worrying) is that
>when I use the Next and EOF methods in a while loop the loop finishes
>before the last item has been copied, so NewCases ends up with one less
>record than Cases.

>According to the help file this shouldn't happen. EOF should not be true
>until after the Next method has been called while the table was on the
>last file. So does anyone know why it is doing this? My code is listed
>below.

>with NewCases do begin
>    Cases.First;
>    while not Cases.EOF do begin
>        Append;
>        for Index:=0 to Cases.FieldCount-1 do
>            Fields[Index].AsString:=Cases.Fields[Index].AsString;
>            Cases.Next
>    end;
>end

>Thanks in advance for any help,
>    Ian
>--
>Ian Dunn                     I...@polyhedron.com

--
Dan Brennand
CMDC systems, inc.
Configuration Management and Document Control: Consulting, Software,
and the only comprehesive textbook on this subject.
visit us at www.cmdcsystems.com
[Remove the SPAM from my e-mail address]

Re:EOF returns true before accessed last record (Delphi 1)


Doh, I knew it would be something silly like that. And you're right
BatchMove would be easier, I forgot about that. Thanks.

In article <38b421c0.75488...@news.dimensional.com>, Dan Brennand
<d...@SPAMcmdcsystems.com> writes

Quote
>I think your problem may be that you are not explicitly posting the
>data. The Next method will post all but the last row; but the last
>time it is called, there is no record to go to, so it does nothing.

>BTW, wouldn't it be easier to use BatchMove?

>HTH,
>Dan

>On Wed, 23 Feb 2000 16:44:34 +0000, Ian Dunn <I...@polyhedron.com>
>wrote:

--
Ian Dunn                     I...@polyhedron.com

Re:EOF returns true before accessed last record (Delphi 1)


The "CheckBrowseMode" method is really handy to use after a loop.  It
checks the state of the database and issues appropriate method-calls to
return it to "Browse" state.

Quote
> In article <38b421c0.75488...@news.dimensional.com>, Dan Brennand
> <d...@SPAMcmdcsystems.com> writes
> >I think your problem may be that you are not explicitly posting the
> >data. The Next method will post all but the last row; but the last
> >time it is called, there is no record to go to, so it does nothing.

> >BTW, wouldn't it be easier to use BatchMove?

> Ian Dunn                     I...@polyhedron.com

--
--------------------------------------------------------------------
Sundial Services :: Scottsdale, AZ (USA) :: (480) 946-8259
mailto:i...@sundialservices.com  (PGP public key available.)
Quote
> Why =shouldn't= it be quick and easy to keep your database online?
> ChimneySweep(R):  "Click click, it's fixed!" {tm}
> http://www.sundialservices.com/products/chimneysweep

Other Threads