Microsoft KB Archive/112403

{| = PRB: Function or Procedure in Setup Causes Screen to Quit =
 * width="100%"|

ID: Q112403

2.50 2.50a 2.50b | 2.50 2.50a 2.50b | 2.50b

WINDOWS         | MS-DOS           | MACINTOSH kbprg kbprb 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

Keywords         : FxtoolSbuilder Version          : 2.50 2.50a 2.50b | 2.50 2.50a 2. Platform         : MACINTOSH MS-DOS WINDOWS
 * }