Microsoft KB Archive/37348

From BetaArchive Wiki
< Microsoft KB Archive
Revision as of 17:55, 18 July 2020 by 3155ffGd (talk | contribs) (importing KB archive)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Base


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

Article ID: 37348

Article Last Modified on 8/16/2005



APPLIES TO

  • 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

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: KB37348