How do you get lines from a file.

In this category you can exchange your programming questions and solutions.
Post Reply
albert
Posts: 24
Joined: Wed Jun 24, 2009 12:39 am

How do you get lines from a file.

Post: # 444Post albert
Mon Jun 29, 2009 2:29 am

I`m wondering how do you line input data from a file??

fred
Posts: 54
Joined: Thu Apr 23, 2009 10:08 am

How do you get lines from a file.

Post: # 445Post fred
Mon Jun 29, 2009 7:14 am

You ?can use the object FileStream

as an example a small program i use:

dim filenaam as string
dim f as FileStream
dim regel as string

filenaam = Trim$(Command$)
const fnxlog="fnx.log"

if FileExists(fnxlog)=true then
?print filenaam
?f.Open(fnxlog)
?while f.Position < f.Size
? ?regel=f.ReadLine
? ?if Left$(regel,6)="error:" then
? ? ?print filenaam+":"+regel
? ?else
? ? ?print regel
? ?end if
?wend
?f.Close
end if

Instead of while f.Position < f.Size you could use f.LineCount in a for loop


albert
Posts: 24
Joined: Wed Jun 24, 2009 12:39 am

How do you get lines from a file.

Post: # 446Post albert
Mon Jun 29, 2009 8:56 pm

I got it working it in my program Cyph256V2 over on the files page under SillyCypher. its the last one on the page.


Post Reply