RESTORE SCREEN FROM Mvar Produces "Variable 'Mvar' Not Found"

Last reviewed: June 28, 1995
Article ID: Q113539
The information in this article applies to:
  • Microsoft FoxPro for Windows, versions 2.5, 2.5a, 2.5b, and 2.6
  • Microsoft FoxPro for MS-DOS, versions 2.0, 2.5, 2.5a, 2.5b, and 2.6
  • Microsoft FoxPro for Macintosh, version 2.5b

SYMPTOMS

The RESTORE SCREEN FROM <memory_variable> command produces a "Variable

'memory_variable' not found" error message. These symptoms may occur when
you convert a dBASE IV application that exploits the global nature of a variable that contains a screen image.

CAUSE

In FoxPro, the scope of the variable created by SAVE SCREEN TO <memory_variable> is private. The variable therefore ceases to exist when execution of the function or procedure in which it was created terminates due to a RETURN statement.

In dBASE IV, the scope of the variable created by SAVE SCREEN TO <memory_variable> is global. The variable therefore continues to exist when execution of the function or procedure in which it was created terminates due to a RETURN statement.

RESOLUTION

To avoid this problem and emulate the behavior of dBASE IV, modify the dBASE IV program by creating a PUBLIC variable to hold the screen image.

For an example of this modification, see "Workaround" in the "More Information" section below.

MORE INFORMATION

Steps to Reproduce Problem

When executed in dBASE IV 2.0, the following code will not produce an error message. When executed in FoxPro, however, this code will produce an error message.

   PROCEDURE ScreScop

        @ 10,10 SAY "Hello World"

        DO ScrnSave

        RESTORE SCREEN FROM myscreen

   RETURN

   PROCEDURE ScrnSave

        * In dBASE, this command creates a variable
        * called myscreen.  The variable has a global
        * scope, so it continues to exist when execution
        * of PROCEDURE ScrnSave is terminated by the
        * RETURN statement.

        SAVE SCREEN TO myscreen

        CLEAR

   RETURN

Workaround

The following code sample has been modified so that it can be executed in FoxPro without producing an error message.

   PROCEDURE ScreScop

        @ 10,10 SAY "Hello World"

        DO ScrnSave

        RESTORE SCREEN FROM myscreen

   RETURN

   PROCEDURE ScrnSave

        * In this example, a public variable is created
        * to hold the screen image.  This variable will
        * continue to exist when the RETURN statement
        * is executed.  The program will now behave
        * as expected.

        PUBLIC myscreen

        SAVE SCREEN TO myscreen

        CLEAR

   RETURN


Additional reference words: FoxMac FoxDos FoxWin 2.00 2.50 2.50a 2.50b 2.60
errmsg err msg
KBCategory: kb3rdparty kbprg kberrmsg kbcode
KBSubcategory: FxinteropDbase


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: June 28, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.