LINE INPUT#n Drops Null Characters from File; Use INPUT$ (42669)



The information in this article applies to:

  • Microsoft QuickBASIC Compiler for the Apple Macintosh 1.0
  • Microsoft BASIC Interpreter for Apple Macintosh 1.0
  • Microsoft BASIC Interpreter for Apple Macintosh 1.01
  • Microsoft BASIC Interpreter for Apple Macintosh 2.0
  • Microsoft BASIC Interpreter for Apple Macintosh 2.1
  • Microsoft BASIC Interpreter for Apple Macintosh 3.0
  • Microsoft QuickBASIC 1.0
  • Microsoft QuickBASIC 1.01
  • Microsoft QuickBASIC 1.02
  • Microsoft QuickBASIC 2.0
  • Microsoft QuickBASIC 2.01
  • Microsoft QuickBASIC 3.0
  • 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
  • Microsoft GW-Basic Interpreter 3.20
  • Microsoft GW-Basic Interpreter 3.22
  • Microsoft GW-Basic Interpreter 3.23
  • Microsoft Visual Basic Standard Edition for Windows 1.0

This article was previously published under Q42669

SUMMARY

The LINE INPUT #n statement strips null characters (CHR$(0)) from input files. If you want to input null bytes, you must use the INPUT$ function instead of the LINE INPUT #n statement.

MORE INFORMATION

Code Sample

The following code segment will print "helloworld" instead of "hello world":
OPEN "test.dat" FOR INPUT AS #1
LINE INPUT #1, a$
PRINT a$
CLOSE #1
				
where the TEST.DAT data file was created as follows:
OPEN "test.dat" FOR OUTPUT AS #1
PRINT #1, "hello" + CHR$(0) + "world"
CLOSE #1
				

Modification Type:MinorLast Reviewed:1/9/2003
Keywords:KB42669