PRB: RUN Command Won't Work with Variables Prefixed with "M."Last reviewed: June 27, 1995Article ID: Q121823 |
The information in this article applies to:
SYMPTOMSAttempting 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.
CAUSEIn 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.
RESOLUTIONWhen 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 &TOBERUNSTATUS This behavior is by design.
MORE INFORMATIONTo 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
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |