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

Last reviewed: April 25, 1997
Article ID: Q156090
The information in this article applies to:
  • Microsoft Visual FoxPro for Windows, versions 3.0, 3.0b, 5.0, 5.0a
  • Microsoft FoxPro for Windows, version 2.6a

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. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

Steps to Reproduce Behavior

  1. 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
    
    

  2. 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.


KBCategory: kbprg kbbuglist
KBSubcategory: FxprgTable vfoxwinFoxWin buglist2.60a buglist3.00
buglist3.00b buglist5.00
Additional reference words: 5.00 2.60a 3.00 3.00b
Keywords : buglist2.60a buglist3.00 FoxWin FxprgTable vfoxwin vfpbug5.0a kbprg kbbuglist
Version : 2.6a 3.0 3.0b 5.0 5.0a
Platform : WINDOWS
Issue type : kbbug


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: April 25, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.