General information
Category:
Coding, syntax & commands
>Tamar,
>I did most of my preVFP coding in FoxProDos2.5. I believe the behavior of the replace command in VFP is significantly different than in 2.5, however, before completing the end of this sentence I went back and did some testing in 2.5 and sure enough if the current record is at eof() replacements are not done in referenced tables. Was this a generally know bug? error? The 'replace in' command was not available in 2.5. It sure is hard changing the way I write a replace statement after having done it a certain way for 10 years and untold thousands of time.
What Andy said. FWIW, here's what we wrote in HackFox about this:
The fields do not all have to be in the same table. However, there's a gotcha here. The Scope, FOR and WHILE clauses are applied to the controlling table (usually the current work area). If you reach EOF() in that table, no further replacements take place in any table. Despite much yelling by many Xbase programmers over the years, this really isn't a bug. It's supposed to work this way and it's as good a choice as any other behavior in this situation.
Here's the deal. REPLACE lets you change fields of multiple records in multiple tables at once. Suppose you've written a REPLACE that moves data into records from three different tables at once. Suppose further that the REPLACE has a scope clause of NEXT 5. What if you reach the end of one of those tables before you've hit five records? For simplicity's sake, the rule has always been that it's the current work area that counts. As long as you're not at EOF() in the current work area, the REPLACE continues (although some data may land in the bit bucket). As soon as you hit EOF() in the current work area, the REPLACE ends. No questions asked. (For explanations of Scope, FOR and WHILE, see "Xbase Xplained.")
Tamar
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only