DOCUMENT:Q121823  10-NOV-1994  [FOXPRO]
TITLE   :PRB: RUN Command Won't Work with Variables Prefixed with "M."
PRODUCT :Microsoft FoxPro
PROD/VER:2.5x 2.60 2.60a | 2.00 2.5x 2.60 2.60a
OPER/SYS:WINDOWS         | MS-DOS
KEYWORDS:kbprg kbprb kbcode

---------------------------------------------------------------------
The information in this article applies to:

 - Microsoft FoxPro for Windows, versions 2.5x, 2.6, 2.6a
 - Microsoft FoxPro for MS-DOS, versions 2.0, 2.5x, 2.6, 2.6a
---------------------------------------------------------------------

SYMPTOMS
========

Attempting to use a variable with an "M." prefix doesn't work when you use
the variable and macro substitution in conjunction with the RUN command.

CAUSE
=====

In FoxPro, the period is used as the macro termination character when used
in combination with literal strings. FoxPro sees the "M." in the variable
name as indicating a request to expand the contents of a variable called M
and concatenate it with the rest of the string it follows. Because there is
no variable named M, the command fails.

RESOLUTION
==========

When a macro directly precedes a literal string, use the terminator. If you
don't, the evaluator attempts to look for a variable name matching the
characters between the ampersand and the first character that would be
invalid in a variable name, such as a space or a quotation mark.

To work around this behavior, declare a working variable as PRIVATE within
your procedure or function that executes the RUN command and use an
indirect approach to achieve the same result. The following code
demonstrates this:

   PROCEDURE MYPROC
   PRIVATE TOBERUN

   TOBERUN = M.SOMEVAR
   RUN &TOBERUN

STATUS
=======

This behavior is by design.

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

To demonstrate this behavior, create a batch file called A.BAT in the
FoxPro directory. Then type the following in the command window:

   TOBERUN = "A.BAT" <Enter>
   RUN &TOBERUN <Enter>

This command will work as expected. Now, modify the variable assignment by
typing the following:

   M.TOBERUN = "A.BAT" <Enter>
   RUN &M.TOBERUN <Enter>

MS-DOS returns the error message, "Bad command or file name," and the batch
file fails to execute.

Additional reference words: FoxDos FoxWin 2.00 2.50 2.50a 2.50b 2.50c 2.60
2.60a
memory variables m. prefix
KBCategory: kbprg kbprb kbcode
KBSubcategory:

=============================================================================

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.

Copyright Microsoft Corporation 1994.