"NUL" Device Behaves Different in QB 4.x than 3.00 or GWBasic (28980)



The information in this article applies to:

  • Microsoft QuickBASIC 4.0
  • Microsoft QuickBASIC 4.0b
  • Microsoft QuickBASIC 4.5
  • Microsoft BASIC Compiler for MS-DOS and OS/2 6.0
  • Microsoft BASIC Compiler for MS-DOS and OS/2 6.0b

This article was previously published under Q28980

SYMPTOMS

The NUL device in QuickBasic Versions 4.00, 4.00b, and 4.50 behaves differently than in previous versions of QuickBasic (or in GW-Basic 3.20).

STATUS

Microsoft has confirmed this to be a bug in QuickBasic Versions 4.00, 4.00b, and 4.50, and in Microsoft Basic Compiler Versions 6.00 and 6.00b for MS-DOS and MS OS/2 (buglist6.00, buglist6.00b). This problem was corrected in Microsoft Basic Professional Development System (PDS) Version 7.00 for MS-DOS and MS OS/2 (fixlist7.00).

MORE INFORMATION

When the program below is run (either inside the QB.EXE editor or from an executable .EXE program), the (incorrect) output is as follows:
   third
				
When run inside the QuickBasic Version 3.00 editor or compiled to an EXE file with QB.EXE Version 3.00, or run in GW-Basic Interpreter Version 3.20, the (correct) output is as follows:
   first
   secondthird
				
With Version 4.00, the string BUFFER$ appears to be reinitialized with each PRINT #1 statement.

If the device name is changed from NUL to anything else, for example TMP, QuickBasic Versions 3.00 and 4.00 produce the same (correct) output.

The following is a code example for this problem:
   open "nul" for random as #1
   field #1, 65 as buffer$
   print#1,"first"
   print#1,"second";
   print #1,"third"
   print buffer$
				

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