Record Variable

Hi All,

My question is:

There is some filter on a Global(Record) Variable.

How can I get the record before last one (predecessor of the last record)

Thanks in advance

No style points here; and I like to respect the backbone …

if not customer.isempty then

if customer.findlast then

if customer.next(-1) = 0 then

error(Your error text here).

And remember that you can’t assume that the Next(-1) call should return a value of 1. Depending on the current key and filters, the return value may be more than 1. You’re really only interested if it returns 0, which means there isn’t another record ahead of the current record within the filtered set.

Hope that helps.

Why the ISEMPTY?

Also shouldn’t it be a FIND(’+’) and not a FINDLAST?

@BABrown,

The IsEmpty function returns a smaller data package than does find(’-’). The first returns a boolean, the second returns a copy of the first record. All of that has to travel across the backbone. It’s a small change in coding style that yields big returns in overall system performance.

Find(’+’) will also work just fine to get the last record in the set. FINDLAST is a newer method to accomplish the same thing, and is one of a series of new functions to manage recordsets that MS have published to help take the burden off of the backbone and improve execution time. I think the new commands were introduced in Version 4.and they may have been improved along the way to 6 and 7. If you haven’t used them much, you might enjoy taking a spare afternoon and designing a few tests that would give you some performance metrics and well as a sense how the new functions behave and whether you can think of any areas that you might could use them to improve performance

I haven’t plowed pillar and post through the documentation on these new functions, nor have I staged any performance trials. I did get the hint from MS though in cside.chm that they’d prefer to see us daily wage earners start taking advantage of the new commends WHEN APPROPRIATE. I think the key point that tips the balance is whether the command returns something big, or something small. As I understand it (gaping escape hatch in the event of being incorrect) the old syntax of FIND(’-’), (’=’), (’+’) etc. would actually bring the entire filtered record set to the local pointer on the client workstation, across the backbone, and then from within that local set, locate and display the record you’re looking for. I believe that the new commands leave the record set on the server and execute the record retrieval function there on the server as well, and then only returns a single record or an error flag. You’re right if you’re thinking that this approach would put a few more clock cycles on the server, but when you consider how much data traffic you’re keeping off of the backbone, it’s a fair trade.

Anyway, I think I’ve used up my work limit. i may even have mads some stuff up, so “trust, but confirm”.

I hope that’s helpful for you. I have some ideas for completely different approaches that you might like better Take a while to ingest all of this, then get back to me if you feel the need.

Regards,

George

Thanks

@George

A few comments to your reply:

In terms of the “IsEmpty”, my point is that it’s a wasted line of code in this situation. There is no need to first check if a record exist, if ou are going to retrieve it. The FIND will handle that for you.

FINDLAST is NOT a newer version of FIND(’+’). It is a different command and has a different use. If you intent to move thru a record set, FINDLAST (or FINDFIRST) are not appropriate commands to use.

I agree that the new commands can be a benefit when properly used. The key is to use them properly.