ReadLine Method

 

Description

 

Reads an entire line (up to, but not including, the newline character) from a TextStream file and returns the resulting string.

 

PowerBASIC Syntax

 

METHOD ReadLine () AS STRING

 

Example [PowerBASIC]

 

#INCLUDE "windows.inc"

#INCLUDE "scrrun.inc"

 

DIM fso AS IFileSystem

DIM pStm AS ITextStream

DIM curLine AS LONG

DIM strText AS STRING

 

' Create an instance of the FileSystemObject

fso = NEWCOM "Scripting.FileSystemObject"

' Open the file for reading

pStm = fso.OpenTextFile(UCODE$("C:\MyFolder\Test.txt"), %IOMode_ForReading, %FALSE, %FALSE)

' Read the file sequentially

WHILE ISFALSE pStm.AtEndOfStream

  curLine = pStm.Line

  strText = pstm.ReadLine

  STDOUT "Line " & FORMAT$(curLine) & ": " & ACODE$(strText)

WEND

' Close the file

pstm.Close

 

Valid XHTML 1.0 Transitional