RUN "PROG.EXE" Fails in QB.EXE Editor; Use RUN "PROG" Instead (37346)



The information in this article applies to:

  • Microsoft QuickBASIC 4.0, when used with:
    • Microsoft BASIC Compiler for MS-DOS and OS/2 6.0
    • Microsoft BASIC Compiler for MS-DOS and OS/2 6.0b
  • Microsoft QuickBASIC 4.0b, when used with:
    • Microsoft BASIC Compiler for MS-DOS and OS/2 6.0
    • Microsoft BASIC Compiler for MS-DOS and OS/2 6.0b
  • Microsoft QuickBASIC 4.5, when used with:
    • Microsoft BASIC Compiler for MS-DOS and OS/2 6.0
    • Microsoft BASIC Compiler for MS-DOS and OS/2 6.0b
  • QBX.EXE environment in Microsoft Basic Professional Development System (PDS) 7.0, when used with:
    • the operating system: MS-DOS

This article was previously published under Q37346

SUMMARY

If you want to RUN a QuickBasic program, such as PROG.BAS, from within the environment, you must type RUN "PROG" instead of RUN "PROG.EXE". RUN "PROG" successfully loads and executes the source file PROG.BAS. RUN "PROG.EXE" will fail in the editor (as designed) but will succeed in an .EXE running outside the editor.

You cannot use the RUN statement to invoke a non-QuickBasic application from within the QB.EXE editor environment; however, you can use the RUN statement from a compiled .EXE program running outside the editor.

To invoke a non-QuickBasic application from within the QB.EXE editor, you can SHELL to it or exit QuickBasic before invoking it.

QB.EXE Version 4.50 fails to give you an immediate error message if you RUN an executable file from inside the editing environment. QB.EXE Version 4.50 attempts to load and execute the .EXE or .COM program as a text module, which will fail. QBX.EXE which comes with Microsoft Basic PDS Version 7.00 behaves the same as QB.EXE 4.50. It loads the .EXE or .COM file and attempts to execute it as Basic source code. This is not considered to be a problem with those products but is a result of incorrect use of the RUN statement in the environment.

MORE INFORMATION

To illustrate the problem, execute (SHIFT+F5) the following program in the QB.EXE editor:
   RUN "WORD.COM"  'Any executable .EXE or .COM file will demonstrate
				
QB.EXE Version 4.50 attempts to load in WORD.COM as a document; this produces garbage characters in the edit window. (WORD.COM is taken from Microsoft Word.) The environment windows are redrawn, and an "Expected: Statement" error box appears. At this point, you can exit QuickBasic, and no harm is done.

If this program is compiled with BC.EXE, the resultant .EXE file successfully transfers control to WORD.COM.

The results of testing with QuickBasic versions earlier than 4.50 are as follows:
  1. QuickBasic Version 4.00b does not produce an error message, but opens a new module ("Untitled"). If compiled with BC.EXE Version 4.00b, the .EXE file runs as expected.
  2. QuickBasic Version 4.00 produces a "Bad File Mode" on the RUN "WORD.COM" statement when run inside the environment, but executes properly when compiled to an .EXE file.
  3. In QuickBasic Versions 2.00, 2.01, and 3.00, the QB.EXE editor successfully executes RUN "WORD.COM" and removes QuickBasic from memory.

Modification Type:MinorLast Reviewed:1/8/2003
Keywords:KB37346