Ahsan Amin


Is there any way to move the pointer of a table to last record apart of 'go bottom' func.

Regards

Ahsan




Re: Move pointer of a table to last record

MarciaAkins


Ahsan Amin wrote:

Is there any way to move the pointer of a table to last record apart of 'go bottom' func.

I am curious: why don't you want to use GO BOTTOM







Re: Move pointer of a table to last record

Ahsan Amin

My supervisor told me to do that




Re: Move pointer of a table to last record

dni

You may try:

Store RECCOUNT() to var1
GO var1





Re: Move pointer of a table to last record

Lightening

is your supervisor a coder



Re: Move pointer of a table to last record

Alex Feldstein

It does not make much sense. GO BOTTOM goes to the bottom record in logical order (i.e. depending on current sort order).

[Update] I forgot to mention what is mentioned below in other responses that it is dependent on index and filters, therefore in many cases though being the easiest, it is not the fastest (in case on using filters this could be significant).





Re: Move pointer of a table to last record

CetinBasoz

Yes of course there a lot of ways to move the pointer to the last record w/o using "go bottom". One of them is on purpose so I assume you're asking that one.

"Go Bottom" is not Rushmore optimized (in VFP9 I doubt it's not) and therefore you could use an existing index created purposefully for such thing. ie:

index on 1 tag myLocator && created once

And execute a go bottom using that index:

set order to tag myLocator descending

locate





Re: Move pointer of a table to last record

Lightening

Yes. If index is on, go bottom might not go to the last record (physically.)

Select yourTable

Set order to

Go bott

OR (with Index on)

Select yourTable

lnLast=recc()

go lnLast





Re: Move pointer of a table to last record

dni

You may try:

DO WHILE .T.
IF .NOT.EOF()
SKIP
ELSE
EXIT
ENDIF
ENDDO





Re: Move pointer of a table to last record

Naomi Nosonovsky

Well, another way would be

select myTable

locate for .f.

eof()





Re: Move pointer of a table to last record

dni

Right, but you may need to decrease with 1 to be on the last record.




Re: Move pointer of a table to last record

MarciaAkins

CetinBasoz wrote:

"Go Bottom" is not Rushmore optimized (in VFP9 I doubt it's not) and therefore you could use an existing index created purposefully for such thing. ie:

index on 1 tag myLocator && created once

And execute a go bottom using that index:

set order to tag myLocator descending

locate

This is from Andy's white paper from a session he gave when VFP 7 first came out on optimizing VFP:

Locate vs Go Top

One of the conventions that has passed into FoxPro mythology is that a LOCATE command is faster than using GO TOP, and that by reversing the index order on a table and using LOCATE performance is better than just using the GO BOTTOM command. However, as the following table shows, this is only true when you are using Filters and is more to do with the fact that the LOCATE command is optimizable (as shown above) than anything else. In VFP 7.0 the difference between the two commands is smaller than in previous versions anyway. Of course, GO TOP and GO BOTTOM retain one huge advantage over LOCATE because they can take an IN <alias> clause, thereby obviating the need to change work areas.

Methodology

GO TOP

LOCATE

GO BOTTOM

INVERT INDEX

AND LOCATE

No Filter

0.030

0.060

0.300

0.070

Filter Not Optimizable

0.010

0.020

0.100

0.071

Filter Partially Optimizable

0.010

< 0.001

0.952

0.140

Filter Fully Optimizable

0.010

< 0.001

1.021

0.140






Re: Move pointer of a table to last record

CetinBasoz

Marcia,

Results show me that "Go Bottom is slower" is not a myth but a fact. However I wouldn't bother with the difference myself.