|
-
June 18th, 2000, 07:04 PM
#1
Line Input #1, line...how do i read ahead one line (or back up one line)
I am loading a file line by line using the LIne Input but at one point i need to look ahead at the next line to decided what to do on the current line...how do i look ahead one line? or how do i use the line Input function and then back up? Any help would be greatly appreciated.
Shane Thomas
p.s. please email replys in addition to the reply of post too
[email protected]
-
June 19th, 2000, 01:25 AM
#2
Re: Line Input #1, line...how do i read ahead one line (or back up one line)
Using Seek() Function you can get the current position inside of your file,
and using Seek Statement you can set this position for desired value.
Good Luck!
-
June 19th, 2000, 01:33 AM
#3
Re: Line Input #1, line...how do i read ahead one line (or back up one line)
You can't do this in Ascii-Mode. Open your File in Binary mode and read with seek() and detect line feeds with the "vbcrlf"-constant or chr(13)/chr(10).
-
June 19th, 2000, 11:26 AM
#4
Re: Line Input #1, line...how do i read ahead one line (or back up one line)
Okay do you have a code example on this? I can find in the help the seek but their examples are not helpful. I am kinda doing this
do while not EOF(1)
Line input #1, inputstring
'need to look ahead one Line input #1 and see whats coming up
if comingupline=0
parse(inputstring)
else
parse2(inputstring)
end if
loop
'this is really loose but hopefully it shows the idea.
Thanks in advance. Shane
-
June 20th, 2000, 02:09 AM
#5
Re: Line Input #1, line...how do i read ahead one line (or back up one line)
Try something like this:
Dim lInputstringlen As Long
Dim lPosition As Long
Open "yourfilename.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, inputstring
lInputstringlen = Len(inputstring)
lPosition = Seek(1) ' gets the current position in the file
Seek #1, lPosition - lInputstringlen ' sets the current position line ahead
Loop
Good Luck!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|