Microsoft KB Archive/156090

= BUG: LOCATE NEXT n or LOCATE REST Fail If Started from BOF =

Article ID: 156090

Article Last Modified on 5/12/2003

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Visual FoxPro 3.0b Standard Edition
 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft Visual FoxPro 5.0a
 * Microsoft Visual FoxPro 6.0 Professional Edition
 * Microsoft FoxPro 2.6a Standard Edition

-



This article was previously published under Q156090



SYMPTOMS
When the LOCATE REST or LOCATE NEXT n commands are used at the beginning of a file (BOF), and if the first record matches the FOR condition, the FOUND function returns .F., and the record pointer cannot be moved off the BOF.



WORKAROUND
Do not use the LOCATE REST or the LOCATE NEXT n commands when at BOF.



STATUS
Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article.



Steps to Reproduce Behavior
  Run the following code from a program (.prg) file: * Start of code example *  CLEAR CREATE TABLE test (field1 c(40)) INSERT INTO test VALUES ('test 1') INSERT INTO test VALUES ('test 2') GO TOP SKIP -1                        && Moves to BOF ? 'BOF after SKIP -1:', BOF LOCATE REST FOR !EMPTY(field1) ? 'FOUND:', FOUND          && Incorrectly returns .F.   ? 'RECNO:' + STR(RECNO,2)   && Returns 1 even if BOF = .T.   ? 'BOF:', BOF               && Should return .F. - should have gone && to record 1 GO TOP ? 'BOF after GO TOP:', BOF LOCATE REST FOR !EMPTY(field1) ? 'FOUND:', FOUND          && Correctly returns .T.   ? 'RECNO:' + STR(RECNO,2)   && Returns 1 ? 'BOF:', BOF              && Returns .F. as expected *  * End of code example  The first FOUND function returns .F., although for the first record, field1 is not Empty. The BOF function returns .T., though the record pointer should have been moved by the LOCATE function.

NOTES:


 * The LOCATE NEXT n command behaves the same way as the LOCATE REST command. The LOCATE RECORD, LOCATE ALL, and LOCATE commands with no scope clause work properly.
 * If the first record does not satisfy the FOR condition, as long as another record matches the FOR condition, the record pointer is moved and the FOUND and the BOF functions are updated correctly.
 * If no record satisfies the FOR condition, both the BOF and the EOF functions return .T.

Additional query words: kbvfp300 kbvfp300b kbvfp500 kbvfp500a kbvfp600

Keywords: kbbug kbprogramming KB156090

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.