# How To Prevent "Too Many READs in Effect" Error Message

ID: Q106697

2.5x 2.6x | 2.00 2.5x 2.6x | 2.5x 2.60a

    WINDOWS   | MS-DOS         | MACINTOSH

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.

     1. Create a new project and name it HANDLER.

     2. 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

     3. Add Handler.prg to the project.

     4. Save the program.

     5. Add a new screen to the project and name it ONE.

     6. 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.

     7. Title the window Screen 1.

     8. Create a SAY object with "RDLEVEL()" as the expression.

     9. Select Refresh Output Field in FoxPro for Windows or Refresh in
        FoxPro for MS-DOS.

10. 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.

11. 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

12. Save the screen without saving the environment.

13. Save the screen again as TWO.

14. Change the window title to Screen 2.

15. Select the push buttons created in step 10 above.

16. Change the first push button prompt to Screen 1.

17. 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

18. Save the screen.

19. Add the screen TWO.SCX to the project.

20. Build the project by choosing the Rebuild Project option.

21. 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.

Additional reference words: FoxDos FoxWin FoxMac 2.00 2.50 2.50a 2.50b 2.50c 2.60 2.60a errmsg err msg KBCategory: KBSubcategory: FxenvMemory

    Keywords          : kberrmsg FxenvMemory
    Version           : 2.5x 2.6x | 2.00 2.5x 2.6x | 2.5
    Platform          : MACINTOSH MS-DOS WINDOWS

Last Reviewed: May 22, 1998 © 1999 Microsoft Corporation. All rights reserved. Terms of Use.