Microsoft KB Archive/108668: Difference between revisions

From BetaArchive Wiki
(importing KB archive)
 
m (Text replacement - ">" to ">")
 
(2 intermediate revisions by the same user not shown)
Line 18: Line 18:
== RESOLUTION ==
== RESOLUTION ==


To obtain the same results in FoxPro for Windows, add a #DEFINE preprocessor directive when you are assigning a value to the system memory variable _STARTUP. For an example, see "Workaround" in the "More Information" section below.
To obtain the same results in FoxPro for Windows, add a #DEFINE preprocessor directive when you are assigning a value to the system memory variable _STARTUP. For an example, see "Workaround" in the "More Information" section below.


== MORE INFORMATION ==
== MORE INFORMATION ==


This behavior is documented in the Help files for FoxPro for MS-DOS and FoxPro for Windows. For more information, see the "#IF ... #ENDIF Preprocessor Directive" online Help topic.
This behavior is documented in the Help files for FoxPro for MS-DOS and FoxPro for Windows. For more information, see the "#IF ... #ENDIF Preprocessor Directive" online Help topic.


=== Steps to Reproduce Behavior ===
=== Steps to Reproduce Behavior ===
Line 35: Line 35:
<pre>  to save the program and close the window:
<pre>  to save the program and close the window:


       #IF &quot;TEST&quot; $ _startup
       #IF "TEST" $ _startup
           ? &quot;TEST mode&quot;
           ? "TEST mode"
       #ELSE
       #ELSE
           ? &quot;PRODUCTION mode&quot;
           ? "PRODUCTION mode"
       #ENDIF
       #ENDIF
</pre>
</pre>
3. In the Command window, issue the following commands:
3. In the Command window, issue the following commands:
<pre>      _STARTUP = &quot;TEST by &lt;your name&gt;&quot;
<pre>      _STARTUP = "TEST by <your name>"
       COMPILE test.prg
       COMPILE test.prg
       DO test.prg
       DO test.prg


   The #IF ... #ENDIF statements will return &quot;TEST mode.&quot;
   The #IF ... #ENDIF statements will return "TEST mode."
</pre>
</pre>
4. Load FoxPro for Windows and repeat steps 1-3. The #IF ... #ENDIF
4. Load FoxPro for Windows and repeat steps 1-3. The #IF ... #ENDIF
<pre>  statements will return &quot;PRODUCTION mode.&quot;
<pre>  statements will return "PRODUCTION mode."
</pre>
</pre>
=== Workaround ===
=== Workaround ===


To obtain the same results (&quot;TEST mode&quot;) in FoxPro for Windows, add a #DEFINE preprocessor directive when you are assigning a value to the system memory variable _STARTUP in the TEST.PRG program. For example:
To obtain the same results ("TEST mode") in FoxPro for Windows, add a #DEFINE preprocessor directive when you are assigning a value to the system memory variable _STARTUP in the TEST.PRG program. For example:


<pre>    #DEFINE _STARTUP &quot;TEST by &lt;your name&gt;&quot;
<pre>    #DEFINE _STARTUP "TEST by <your name>"
     #IF &quot;TEST&quot; $ _startup
     #IF "TEST" $ _startup
           ? &quot;TEST mode&quot;
           ? "TEST mode"
     #ELSE
     #ELSE
           ? &quot;PRODUCTION mode&quot;
           ? "PRODUCTION mode"
     #ENDIF
     #ENDIF
</pre>
</pre>
If you recompile and run the TEST.PRG file, it should now return &quot;TEST mode&quot; in FoxPro for Windows.
If you recompile and run the TEST.PRG file, it should now return "TEST mode" in FoxPro for Windows.
Additional reference words: FoxDos FoxWin 2.50 2.50a 2.50b compiler run time runtime KBCategory: kbenv kbprg KBSubcategory: FxenvMemory
Additional reference words: FoxDos FoxWin 2.50 2.50a 2.50b compiler run time runtime KBCategory: kbenv kbprg KBSubcategory: FxenvMemory
|}
|}

Latest revision as of 17:46, 20 July 2020

#IF ... #ENDIF Returns Different Results in FPD and FPW

ID: Q108668

The information in this article applies to:

  • Microsoft FoxPro for MS-DOS, versions 2.5, 2.5a, 2.5b
  • Microsoft FoxPro for Windows, version 2.5, 2.5a, 2.5b

SYMPTOMS

In FoxPro for MS-DOS, if a system memory variable such as _STARTUP is stored with a value prior to compilation, _STARTUP can be evaluated with the #IF ... #ENDIF statements at compile time.

In FoxPro for Windows, the #IF ... #ENDIF statements will not evaluate the system memory variable _STARTUP at compile time even though the system memory variable _STARTUP contains a value prior to compilation.

RESOLUTION

To obtain the same results in FoxPro for Windows, add a #DEFINE preprocessor directive when you are assigning a value to the system memory variable _STARTUP. For an example, see "Workaround" in the "More Information" section below.

MORE INFORMATION

This behavior is documented in the Help files for FoxPro for MS-DOS and FoxPro for Windows. For more information, see the "#IF ... #ENDIF Preprocessor Directive" online Help topic.

Steps to Reproduce Behavior

Load FoxPro for MS-DOS, and then follow the steps below:

1. In the Command window, type:

      MODIFY COMMAND TEST

2. Type the following code into the edit window, and then press CTRL+W

   to save the program and close the window:

       #IF "TEST" $ _startup
           ? "TEST mode"
       #ELSE
           ? "PRODUCTION mode"
       #ENDIF

3. In the Command window, issue the following commands:

       _STARTUP = "TEST by <your name>"
       COMPILE test.prg
       DO test.prg

   The #IF ... #ENDIF statements will return "TEST mode."

4. Load FoxPro for Windows and repeat steps 1-3. The #IF ... #ENDIF

   statements will return "PRODUCTION mode."

Workaround

To obtain the same results ("TEST mode") in FoxPro for Windows, add a #DEFINE preprocessor directive when you are assigning a value to the system memory variable _STARTUP in the TEST.PRG program. For example:

     #DEFINE _STARTUP "TEST by <your name>"
     #IF "TEST" $ _startup
           ? "TEST mode"
     #ELSE
           ? "PRODUCTION mode"
     #ENDIF

If you recompile and run the TEST.PRG file, it should now return "TEST mode" in FoxPro for Windows. Additional reference words: FoxDos FoxWin 2.50 2.50a 2.50b compiler run time runtime KBCategory: kbenv kbprg KBSubcategory: FxenvMemory


Last Reviewed: June 27, 1995
© 1999 Microsoft Corporation. All rights reserved. Terms of Use.