The COUNT command reports that only one row is visible! Here's why:
No, it's not a bug in dBASE.
The UNIQUE clause of the INDEX ON command tells dBASE to exclude from the index any records whose key values are already in the index. But deleted records can be included in the index, regardless of whether SET DELETED is ON or OFF. Here is what happens when the index is being built:
Record 1 is added to the index (“London”)
Record 2 is added to the index (“Montreal”) - even though it is flagged for deletion.
Record 3 is not added to the index, because there's already a “Montreal” key value in the index.
The COUNT command counts the non-deleted keys in the active index - and there's only one.
Avoiding the trap
This quirk of unique indexes can manifest itself in your applications with potentially harmful results. For example, SEEK('Montreal') will return false after you run dQuiz1.prg - and this is certainly not a behavior one would desire.
To prevent this from happening, you can ensure that deleted keys are excluded from your unique indexes. For example:
index on City tag City for not deleted() unique
to the dQuiz