Microsoft KB Archive/37348
Article ID: 37348
Article Last Modified on 8/16/2005
- Microsoft Visual Basic for MS-DOS
- Microsoft QuickBasic 4.0
- Microsoft QuickBASIC 4.0b
- Microsoft QuickBasic 4.5 for MS-DOS
- Microsoft BASIC Compiler 6.0
- Microsoft BASIC Compiler 6.0b
- Microsoft BASIC Professional Development System 7.0
- Microsoft BASIC Professional Development System 7.1
This article was previously published under Q37348
A Visual Basic for MS-DOS, version 1.0 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 listed below demonstrate this behavior.
If you type "PROG1 /Z" on the MS-DOS command line, "/Z" is returned with the COMMAND$ function in both programs listed below, 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.
' To try the following examples in VBDOS.EXE: ' 1. From the File menu, choose New Project. ' 2. Copy the code example to the Code window. ' 3. Press F5 to run the program. 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
Additional query words: VBmsdos QuickBas BasicCom 1.00 4.00 4.00b 4.50 6.00 6.00b 7.00