Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
GOTO on Filtered data
Message
 
 
À
19/11/2004 16:30:03
Ken Dibble
Southern Tier Independence Center
Binghamton, New York, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 7 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
00962533
Message ID:
00963230
Vues:
7

>>The GOTO < Record # > command pays no attention to SET FILETER or SET DELETE ON.
>
>That's not documented in the Help for the GOTO topic, BTW.


Not directly. Help says that in the form GO nRecordNumber GO command moves a record pointer moves to the specified physical record number. It doesn't say that it can be affected buy anything and it's correct. On other hand, it failed to mention that GO TOP and GO BOTTOM do affected by SET FILETER or SET DELETE ON.

>And I'm still confused. It's a good thing I'm not afraid of appearing ignorant online. <g>
>
>It seems to me that in my code, if the BROWSE issued LOCATE, then the second BROWSE would show the pointer on the first record, not the second.
>
>If I do this with the same cursor:
>
>
>GO 10
>
>nRec = RECNO()
>
>SET FILTER TO IntField <> 10
>
>LOCATE
>
>? RECNO()  && 1
>
>GO nRec
>
>BROWSE  && Record 10 is not visible. The pointer is on Record 9.
>
>
>The Help for LOCATE says:
>
>"If you use the LOCATE command without the FOR expression, Visual FoxPro positions the record pointer at the first logical record. This is faster than using GO TOP when a filter is in use or when DELETED is ON."
>
>From this I conclude that a bare LOCATE should always put the pointer on the first record in the table. Granted that "logical" record isn't the same as "physical" record, but "first" means "first", right? It doesn't mean "the first record that the filter will let us show in a BROWSE window after the record we went to that can't be shown", right? Or, in the case of the above code, "the nearest record that satisfies the filter"? With no index on the cursor, it doesn't matter what nRec was; the first record is the record whose fields contain 1 and "1". It looks to me like the BROWSE isn't just issuing an implicit LOCATE. It's a lot more complicated than that. It's more like:
>
>
>IF NOT EOF()
>     LOCATE REST FOR [filter condition]
>ENDIF
>
>IF EOF()
>     SKIP -1
>
>     DO WHILE NOT [filter condition] AND NOT BOF()
>          SKIP -1
>     ENDDO
>ENDIF
>
>
>Have I got this right?
>
I should say "In most cases it does issue an implicit LOCATE" but I didn't remeber that there were special cases at the time when I posted reply.
The one of such special cases is when record pointer is positioned on the last record in the table and this record doesn't satisfy filter criteria. In this case VFP checks if previous records satisfies the filter critire. If it does than record pointer is moved to it otherwise LOCATE is issued.
IF RECNO() = RECCOUNT() AND NOT EVAL(< filter condition >)
	SKIP -1
ENDIF
IF NOT EVAL(< filter condition >)	
	LOCATE
ENDIF	
I'm not sure if there are any other such special conditions though.
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform