New COMMAND$ Will Not Pass with RUN from within VB Program

ID: Q37348


The information in this article applies to:
  • Microsoft Visual Basic Standard and Professional Editions for MS-DOS, version 1.0
  • Microsoft QuickBASIC for MS-DOS, versions 4.0, 4.0b, 4.5
  • Microsoft BASIC Compiler for MS-DOS and MS OS/2, versions 6.0, 6.0b
  • Microsoft Basic Professional Development System (PDS) for MS-DOS and MS OS/2, versions 7.0, 7.1


SUMMARY

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.


MORE INFORMATION

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

Keywords :
Version : MS-DOS:1.0,4.0,4.0b,4.5; :6.0,6.0b,7.0,7.1
Platform : MS-DOS
Issue type :


Last Reviewed: December 9, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.