KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q37348: New COMMAND$ Will Not Pass with RUN from within QB Program

Article: Q37348
Product(s): See article
Version(s): 3.00 4.00 4.00b
Operating System(s): MS-DOS
Keyword(s): ENDUSER | B_BasicCom | mspl13_basic
Last Modified: 12-JAN-1990

A QuickBASIC program will return the COMMAND$ as expected, but the RUN
statement with an appended command string will not pass the COMMAND$
to the new program. Instead, the original COMMAND$ from the first
program is passed to the second (RUN) program. The two programs below
demonstrate this behavior.

This information applies to Microsoft QuickBASIC Versions 4.00, 4.00b,
and 4.50, to Microsoft BASIC Compiler Versions 6.00 and 6.00b for
MS-DOS and MS OS/2, and to Microsoft BASIC PDS Version 7.00 for MS-DOS
and MS OS/2.

If you type "PROG1 /Z" on the MS-DOS command line, "/Z" is returned
with the COMMAND$ function in both programs, regardless of what is
entered for X$ in Prog1. Because the RUN statement is used with a
quoted string, the " + X$" is concatenated to the program name string.
This means that if X$ equals "/B", then the RUN statement is actually
RUN "PROG2.EXE/B", which is not a valid filename.

The following is a code example:

REM   *** Prog1 ***
PRINT "Here is the COMMAND$: "; COMMAND$
INPUT "Enter the new COMMAND$"; X$
RUN "PROG2.EXE" + X$                       'Either .BAS or .EXE
END

REM   *** Prog2 ***
PRINT "Here is the COMMAND$: "; COMMAND$
END

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 1986-2002.