Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SCAN loops : Continuing the discussion 7

Status
Not open for further replies.

Mike Lewis

Programmer
Jan 10, 2003
17,516
Scotland
There was a thread here last week about the behaviour of SCAN loops - in particular, certain traps that developers might fall into. The entire thread was removed by Tek Tips management because of offensive language by the OP.

Despite that, the thread did contain some useful points, and I thought it would be worth continuing the discussion. In particular:

1. It is rarely necessary to test for EOF() within a SCAN loop. In other words, code like this is rarely necessary:

Code:
SCAN
  IF EOF()
    EXIT
  ENDIF
ENDSCAN

By definition, the the SCAN loop will terminate at the end of file.

2. A SCAN loop on an empty table does nothing. It will simply go straight from the SCAN to the ENDSCAN.

3. The behaviour of a SCAN loop on a table that only contains deleted records will depend on the setting of DELETED. With DELETED ON, it is the same as if the table was empty. With DELETED OFF, the records are processed as usual.

4. Point 1 does not necessarily apply if the loop includes one or more SKIPs. If the SKIPs take you beyond EOF, there is no error generated.

5. The SCAN loop always starts at the top of the table. There is never any need to do this:

Code:
GO TOP
SCAN
  ...
ENDSCAN

6. I don't think this was mentioned in the thread, but it's worth remembering that SKIP loops will operate on the correct alias, even if you change the work area within the loop. In other words, in code like this:

Code:
SELECT Table1
SCAN

   && do something
   
   SELECT Table2
   && do something with another table

  SELECT Table1
ENDSCAN

the final SELECT is unnecessary. The SCAN will automatically apply the correct alias when looping back to the start.


I hope this is of interest. Feel free to add your comments and suggestions (but without the insults and personal attacks, of course).

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
OK, since the conversation has moved on to Foxpro-related films, let me test your knowledge with this question:

Which noted Foxpro programmer once went out on a date with Marylin Monroe?

(For the avoidance of doubt, this is the real Marylin Monroe [the star of Some Like it Hot, etc), not someone who happens to have the same name. And I when I day a "date", I mean that they actually went out together [in fact, to see a movie]).

Answer with spoiler tags please.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
I think it is
The author of Visual FoxPro to Visual Basic .NET, Les Pinter

Chriss
 
Hm I thought he wrote something about the appointment with a famous person in the preface. Let me check who else it was, then. This may take a while...

Chriss
 
Didn't he play Jeff Miller in 3 seasons of Lassie?

He and Marilyn Monroe saw the 'River of no return' together.

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Mike Gagnon said:
Didn't he play Jeff Miller in 3 seasons of Lassie?

Spot on, Mike.

Mike Gagnon said:
He and Marilyn Monroe saw the 'River of no return' together.

They were IN River of No Return together, but the film they went to see together was the premier of The 5000 Fingers of Dr. T in 1953. (I'd never heard of it either.)

For those who still don't know the answer, look at Tamar's post above. In the meantime, here is the picture of them together.

Tom_Rettig_tehhvm.jpg


Did anyone here ever meet him?

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Mike Lewis
Beg to differ

Was Marilyn Monroe's youngest date ever when he escorted her to the premiere of River of No Return (1954) in 1954.




If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Mike G, you might be right that he escorted her to the premiere of River of No Return in 1954. It seems likely, given that they both appeared in the film. But there are many sources that say that the photo I posted was from the premiere of The 5000 Fingers of Dr. T. See here for example.

But I don't insist that I am right. This isn't really my area of expertise.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
As I recall, Tom created some great programs in FP and was one of the actors who played the boy (I forget his name) in the TV series "Lassie", a very special collie.

Steve
 
Yes, I met him. He was still speaking at FoxPro events when I first started attending and then speaking. OTOH, I wasn't invited to the parties he used to give at DevCon, but I'm pretty sure I wouldn't have been comfortable there, based on some of the hints I picked up about them.

Tamar
 
Steve Meyerson said:
was one of the actors who played the boy (I forget his name) in the TV series "Lassie"

Jeff Miller



If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top