Microsoft KB Archive/72682

= If LF+CR+LF, LINE INPUT# Fails to Treat CR+LF as End-of-Line =

Article ID: 72682

Article Last Modified on 11/21/2006



This article was previously published under Q72682



SYMPTOMS
If a LINE INPUT# statement reads a linefeed plus carriage return plus linefeed sequence (LF+CR+LF), then LINE INPUT# will not treat the CF+LF as an end-of-line marker, and will continue reading data until it reads CR+LF that does not have a leading linefeed.



STATUS
Microsoft has confirmed this to be a bug in Microsoft QuickBasic versions 2.0, 2.01, 3.0, 4.0, 4.0b, and 4.5 for MS-DOS (buglist4.50, buglist4.00b, buglist4.00, buglist3.00, buglist2.01, buglist2.00); in Microsoft Basic Compiler versions 6.0 and 6.0b for MS-DOS and MS OS/2; and in Microsoft Basic Professional Development System (PDS) versions 7.0 and 7.1 for MS-DOS and MS OS/2. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

Note that LINE INPUT# has no problem treating CR+LF+CR+LF as two (empty) records, as long as no LF leads the sequence.



MORE INFORMATION
The following program demonstrates this problem. After the program writes three lines of data to the file, including two embedded LF+CR+LF sequences, the LINE INPUT# loop only inputs three lines. You might expect LINE INPUT# to separately input the following five strings into text$ in the WHILE...WEND loop: hello world  RING RING hello world Instead, the WHILE...WEND cycles just three times, and LINE INPUT# inputs the following three strings into text$: hello world RINGRING hello world

Code Sample
CLS OPEN &quot;input.tst&quot; FOR OUTPUT AS #1 PRINT #1, &quot;hello world&quot; PRINT #1, CHR$(10); CHR$(13); CHR$(10); &quot;RING&quot;; ' &quot;;&quot; Concatenates PRINT #1, CHR$(10); CHR$(13); CHR$(10); &quot;RING&quot;  ' these two lines. PRINT #1, &quot;hello world&quot; CLOSE #1

OPEN &quot;input.tst&quot; FOR INPUT AS #1 WHILE NOT EOF(1) n = n + 1 LINE INPUT #1, text$ PRINT &quot;RECORD #&quot;; n; &quot; LENGTH=&quot;; LEN(text$), &quot;CONTENTS:&quot;; text$ WEND CLOSE #1

Additional query words: QuickBas BasicCom 2.00 3.00 4.00 4.00b 4.50 buglist6.00 buglist6.00b buglist7.00 buglist7.10

Keywords: KB72682

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.