File Reading Progress.

BlitzMax Forums/BlitzMax Programming/File Reading Progress.

So here's the problem, I have to show the progress of reading all the files in a file, I was going to approach it by changing the progress by how many lines its read to the amount of lines in the file.. But how can i get the lines in the file without reading the file and adding 1 to the amount of lines each time i read a line?

Or is there some kind of approach where i can check how many more bytes are available to read?

I guess i didn't look at the declaration of Eof(), is just returns true or false, not bytes available..

I've solved the problem using StreamPos, you can tell me to look into things more before i spam this forum :D.

you have streampos()
EDIT: i see you found that, anyway, have fun with the code:

Graphics 800,600


out=WriteStream("TestFile.ini")

If Not out RuntimeError "Failed to open a WriteStream to file mygame.ini"

For x = 1 To 2000
	WriteLine out,"Line"+x
Next 

CloseStream out


in = ReadStream("TestFile.ini")
size = StreamSize(in)
Print size

While Not Eof(in)
	
	line$ = ReadLine( in ) 
	pos = StreamPos(in)/100
	
		SetColor 155,155,0
		DrawRect 100,100,pos,30
		SetColor 255,0,0
		DrawText pos,100,100
		DrawText "LoAdInG "+line,100,140
		DrawText StreamPos(in)+" of  "+size,100,160

	Flip
	Cls
	If KeyDown(Key_ESCAPE) Then Exit
Wend


CloseStream in



Try something like this:
File nibbler

Its nice to see how long a load will take, but dont make it 2x longer just to see a progress bar.

Its nice to see how long a load will take, but dont make it 2x longer just to see a progress bar.


I realize that, but these files are small so it doesn't matter.

.

... just count the number of files to load ...


Who said I was loading a ton of small files?

I'm just doing file progress cause i want to know if my app has gotten stuck or something of that sort.

.

@Plash:
From the beginning of this thread:
:I have to show the progress of reading all the files in a file


Never noticed that before, it should be 'I have to show the progress of reading all the recently viewed (5) files in a folder', its just a simple typing-to-fast typo.


BTW, I don't recall mentioning anything about a "ton" of anything.


I was expressing what you said, now i know why you said it how you did, because of my typo in the first post.

.

oh ok. It's alllll good.


Never wanted to start a war :).