Microsoft KB Archive/42669

From BetaArchive Wiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
Knowledge Base


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

Article ID: 42669

Article Last Modified on 11/21/2006



APPLIES TO

  • Microsoft QuickBasic Compiler for Macintosh 1.0
  • Microsoft BASIC Interpreter 1.0
  • Microsoft BASIC Interpreter 1.01 for Macintosh
  • Microsoft BASIC Interpreter 2.0
  • Microsoft BASIC Interpreter 2.1 for Macintosh
  • Microsoft BASIC Interpreter 3.0 for Macintosh
  • 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 for MS-DOS
  • Microsoft BASIC Compiler 6.0
  • Microsoft BASIC Compiler 6.0b
  • Microsoft GW-BASIC Interpreter 3.20
  • Microsoft GW-BASIC Interpreter 3.22
  • Microsoft GW-BASIC Interpreter 3.23
  • Microsoft Visual Basic 1.0 Standard Edition



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
                


Additional query words: QuickBas BasicCom MQuickB 1.00 2.00 2.10 3.00 3.20 4.00 4.00b 4.50 6.00 6.00b 7.00 7.10

Keywords: KB42669