QB64 and LINE INPUT with Unix text filesby qbguy (no login)First, I am going to make a program to create a text file with Unix line endings. I am outputting the CHR$(10)'s using QBASIC here. And yes, I am able to use the Unix cat command even though I am on Windows so booyah. C:\qb64>cat > test1.bas OPEN "test.txt" for output as #1 PRINT #1, "Hello, World!"; CHR$(10); PRINT #1, "The quick brown fox jumps over the lazy dog."; CHR$(10); PRINT #1, "Goodbye."; CHR$(10); CLOSE #1 SYSTEM ^Z C:\qb64>qbasic /run test1.bas Now I am going to use LINE INPUT in QBASIC to demonstrate that QBASIC considers a "line" of text to be a "series of characters ending with a CR-LF" C:\qb64>cat > test2.bas OPEN "test.txt" FOR INPUT AS #1 LINE INPUT #1, X$ PRINT X$ CLOSE #1 SYSTEM ^Z C:\qb64>qbasic /run test2.bas Hello, World! The quick brown fox jumps over the lazy dog. Goodbye. As you can see, QBASIC needs a complete CR-LF (CHR$(13)+CHR$(10)), not just a line feed. Now I am going to compile and run the same program with QB64: C:\qb64>compile test2.bas (SDL window pops up: COMPILING C++ CODE INTO EXE...) Now I run test2.exe and I get just the first line: "Hello, World!" I actually like this handling of Unix type text files as opposed to QBASIC's way of handling newlines. Maybe we could have the commands Option Newline Auto and Option Newline DOS as well as maybe Option Newline Unix. from IP address 76.210.141.14 |
| Response Title | Author and Date |
| yeah qbasic has the same problem loading unix lf txt files in dosbox | mennonite on Jun 1 |
| QB64 considers LF or CR or LF+CR or CR+LF to mean begin a new line | on Jun 1 |