Home » Uncategorized » FoxPro Tips – Twice Baked
Sep
21

FoxPro Tips – Twice Baked

Lots of people are remembering tips and tricks Drew Speedie passed along over the years. It was one of his many specialties. In the spirit of this I want to pass along something I have accidentally demonstrated three times in the last couple of weeks and something I learned this afternoon.

With the BROWSE window open you can press Ctrl+F to bring up the VFP Find dialog. Enter in any text and click on the Find Next button and VFP will search all the columns in all the records looking for the text you typed in. It is a quick and dirty way to find keys, or strings in columns, or numbers in numeric data. This does not work with memo fields or date/datetime fields. The searches start with the current record.

I noted this was accidentally demoed. I cannot say how often I use this little trick, but it has been around forever. Fortunately a brave developer was not afraid to ask about what I did when I “demoed” it at the Detroit Area Fox User Group and a couple of others learned the trick as well. I was looking for something in the DataExplorer metadata at the time. Same thing happened on my southern California tour last week.

Today I was working at a client and did another accidental demo of the feature. This developer has been using FoxPro since the 80′s and was surprised when he saw me look up data in a cursor. His usual technique is BROWSE FOR something. Two different approaches to the same end.

So my friend turns around and shares a cool tip I did not know about. Adding the DISTINCT clause into an aggregate function in a SQL Select statement:

USE (_samples+"data\customer") IN 0 SHARED

SELECT ;    COUNT(*) as nTotalCustomerRecs, ;    COUNT(DISTINCT Country) as nDistinctCountries ;  FROM Customer  INTO CURSOR curBeAmazed

I was amazed by the result set! I tested this all the way back to VFP 5.0 and it works (except for the _samples system memvar).

I swear you can learn so much about development and Visual FoxPro by watching any other developer. It does not matter what your experience is, or what the other developer’s experience is. I have seen this happen repeatedly throughout my career. It is so cool to do pair programming and gain this knowledge. This is also a common experience attending conference or user group presentations.

Drew would be proud!

Add reply