PRB: Function or Procedure in Setup Causes Screen to Quit

Last reviewed: April 30, 1996
Article ID: Q112403
The information in this article applies to:
  • Microsoft FoxPro for Windows, versions 2.5, 2.5a, and 2.5b
  • Microsoft FoxPro for MS-DOS, versions 2.5, 2.5a, and 2.5b
  • Microsoft FoxPro for Macintosh, version 2.5b

SYMPTOMS

A screen created by the Screen Builder does not run.

CAUSE

The screen's Setup snippet contains a function or procedure.

RESOLUTION

Move the function or procedure to the Cleanup snippet. This is where functions and procedures should be placed.

STATUS

This behavior is by design.

MORE INFORMATION

The code below a procedure or function is not executed unless that procedure or function is called. When the procedure or function is located in the Setup snippet, all the remaining code below it (for the screen) is treated as a part of the procedure or function.

Steps to Reproduce Problem in FoxPro for Windows

  1. Assuming FoxPro is installed in a directory named FOXPROW on drive C, type the following in the Command window:

    USE C:\FOXPROW\TUTORIAL\CUSTOMER CREATE SCREEN test

  2. From the Screen menu, choose Quick Screen.

  3. In the Quick Screen dialog box, choose OK.

  4. From the Screen menu, choose Layout.

  5. Under Options, choose Code.

  6. Under Screen Code And Clauses, choose Screen Setup Code, then choose OK twice.

  7. In the Setup snippet window, type the following:

    WAIT WINDOW "Before function"

    function Test x = "" RETURN x

    WAIT WINDOW "After function"

    NOTE: This behavior also occurs when a procedure is placed in the Setup snippet instead of a function.

  8. Close the Setup snippet window, saving the changes.

  9. From the Program menu, choose Generate.

  10. When prompted to save changes to the screen, choose Yes.

  11. When prompted to save environment information, choose Yes.

  12. In the Generate Screen dialog box, choose Generate.

  13. Close the Screen Design window.

  14. In the Command window, type "DO test.spr" (without the quotation marks).

Note that the first WAIT WINDOW appears. After you press a key to continue, however, the Command window reappears.


Additional reference words: FoxMac FoxDos FoxWin 2.50 2.50a 2.50b
KBCategory: kbprg kbprb
KBSubcategory: FxtoolSbuilder


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 30, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.