Line Property |
Description
Read-only property that returns the current line number in a TextStream file.
PowerBASIC Syntax
Remarks
After a file is initially opened and before anything is written, Line is equal to 1.
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 ' Current line curLine = pStm.Line IF curLine = 3 THEN ' Skip the 3rd line pStm.SkipLine curLine = curLine + 1 END IF ' Skip 10 characters pStm.Skip 10 ' Current column curCol = pStm.Column ' Read 5 characters strText = pStm.Read(5) ' Skip the rest of the line pStm.SkipLine STDOUT "Line " & FORMAT$(curLine) & ", Column " & FORMAT$(curCol) & ": " & ACODE$(strText) WEND ' Close the file pstm.Close
|