QB64.com

QB64 is a modern extended BASIC programming language that retains QBasic/QuickBASIC 4.5 compatibility and compiles native binaries for Windows, Linux, and macOS.

The LINE INPUT # file statement reads an entire line from a text file into a string variable.

Syntax

LINE INPUT #fileNumber&, stringVariable$

Parameter(s)

Description

Error(s)

Example(s)

Finding the number of filenames listed in a file to dimension an array to hold them.


REDIM FileArray$(100) 'create dynamic array
SHELL _HIDE "DIR /B *.* > D0S-DATA.INF"  
IF _FILEEXISTS("D0S-DATA.INF") THEN 
  OPEN "D0S-DATA.INF" FOR INPUT AS #1 
  DO UNTIL EOF(1)
    LINE INPUT #1, file$        'read entire text file line
    filecount% = filecount% + 1
  LOOP
  CLOSE #1
END IF
REDIM FileArray$(filecount%)
PRINT filecount% 

See Also