The information in this article applies to:
- Microsoft FoxPro for Windows, versions 2.5x, 2.6x
- Microsoft FoxPro for MS-DOS, versions 2.0, 2.5x, 2.6x
- Microsoft FoxPro for Macintosh, versions 2.5x, 2.6a
SUMMARY
If a screen runs another screen, the current number of READs in effect is
increased by one. One way to avoid nesting is to have a main program run
the next screen. The EX1 application in the GOODIES\FNDATION subdirectory
illustrates this idea.
MORE INFORMATION
The following steps create a group of screens that can run one another
without increasing READ levels. This example is a simplified version of the
EX1 application.
- Create a new project and name it HANDLER.
- Create a program called Handler.prg containing the following lines of
code:
* This is the main handler program that keeps from building
* READ levels.
* The following variable controls which screen is called, and
* it is changed globally by each screen.
screen_to_call="one.spr"
* The following loop calls the screens.
DO WHILE screen_to_call <> "Quit"
DO (screen_to_call)
ENDDO
- Add Handler.prg to the project.
- Save the program.
- Add a new screen to the project and name it ONE.
- Change the screen type to a window.
NOTE: In FoxPro for MS-DOS, when you choose Screen Layout from the
Screen menu, you are presented with a choice of Desktop or Window.
Select Window. In FoxPro for Windows, choose Layout from the Screen
menu, choose the Window Style button in the Screen Layout dialog box,
and select User from the Type list box.
- Title the window Screen 1.
- Create a SAY object with "RDLEVEL()" as the expression.
- Select Refresh Output Field in FoxPro for Windows or Refresh in
FoxPro for MS-DOS.
- Create a two-button push button set. Type "Screen 2" and "Quit" for the
push button prompts, enter "X" in Variable text box, and select the
Terminate READ On Selection check box.
- Enter the following code in the Valid Code Snippet window:
DO CASE
CASE x = 1
screen_to_call="two.spr"
CASE x = 2
screen_to_call="Quit"
ENDCASE
CLEAR READ
- Save the screen without saving the environment.
- Save the screen again as TWO.
- Change the window title to Screen 2.
- Select the push buttons created in step 10 above.
- Change the first push button prompt to Screen 1.
- Change the code in the Valid Code Snippet as follows:
DO CASE
CASE x = 1
screen_to_call="one.spr"
CASE x = 2
screen_to_call="Quit"
ENDCASE
CLEAR READ
- Save the screen.
- Add the screen TWO.SCX to the project.
- Build the project by choosing the Rebuild Project option.
- Run the HANDLER.PRG program.
Note that the RDLEVEL() command never returns a value greater than 1,
even when you are switching between screens 1 and 2.
For additional information about this topic, please see the following
article in the Microsoft Knowledge Base:
ARTICLE-ID: Q106696
TITLE : Single Screen Set to Prevent "Too Many READs in Effect"
The method described in Q106696 is slower, but requires less memory and
fewer resources.
|