PRB: Calling Screen from Another Without Jumping a READ LevelLast reviewed: April 29, 1996Article ID: Q104054 |
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:
CLEAR READ DO screen2.sprLooking 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:
|
Additional reference words: VFoxWin 3.00 FoxDos FoxWin 2.00 2.50 2.50a
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |