PRB: Calling Screen from Another Without Jumping a READ LevelID: Q104054 2.50x 2.60 2.60a 3.00 | 2.00 2.5x 2.60 2.60a | 2.5x 2.60a
The information in this article applies to:
SYMPTOMSMany FoxPro programmers want to be able to execute one screen from another. This may present problems if the READ command from the calling screen is not cleared before the next screen is executed and more than five screens are executed. The most common error message encountered is "Too many READs in effect," which is the result of having more than five READS in effect, which is a FoxPro limit.
CAUSEThe most common, though incorrect, way to try to solve this problem is to enter something similar to the following code in the VALID clause of a push button on Screen1:
Looking at this code, it appears that the READ command will be cleared and
that Screen2 will then be executed. Actually, the READ command from Screen1
stays in effect, Screen2 is executed, and the Screen1 READ command is not
cleared until the READ command from Screen2 is cleared and control is
returned to Screen1.
This behavior occurs because in order for the CLEAR READ command to be recognized by the current READ command, program control has to be returned to that READ command. In this example, the CLEAR READ command is issued and then program control is immediately transferred to SCREEN2.SPR; the READ command for Screen1 never has a chance to act on the CLEAR READ command and therefore Screen1's READ command is not cleared before the DO command for SCREEN2.SPR is issued.
RESOLUTION*************************************************************************** IMPORTANT: This technique is not intended to replace a foundation READ, but is a way to get around the limitation of not being able to have more than five READs in effect at one time. Because a DO command is being executed from another DO command, there is a form of recursion occurring and the error "DO nesting too deep" will appear if the limit of 32 DO levels is reached. *************************************************************************** To achieve the desired behavior, issue the CLEAR READ command as done above, but don't issue the DO screen2.spr command until after the READ command has been cleared. For example: 1. In the Screen Builder, create a new screen.
2. Create a push button with two prompts: <Screen2> and <Quit>. Make the
3. Open the Setup code snippet and add this line of code:
4. Open the Cleanup code snippet and add these lines of code:
This code example never leaves the originating program, so all variables
declared in each screen set will remain defined until you quit the original
calling screen. The program will have to manually release the memory
variables in the Cleanup code.
Additional reference words: VFoxWin 3.00 FoxDos FoxWin 2.00 2.50 2.50a 2.50b 2.50c 2.60 2.60a errmsg err msg jump KBCategory: kbprb KBSubcategory: FxprgMacrosub
|
Last Reviewed: May 22, 1998 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |