|
Post by tsh73 on Nov 7, 2023 8:57:21 GMT
Sometimes you read and process file, line by line, and it takes time. Sometimes you just whant to show what your program did not hang ;) You do not know how much lines in a file, beforehand (though you can open-read-close file just for that, reading without processing might be pretty fast)
BUT when working a file, you have file length (lof(#1)) and current position (loc(#1)) So you can measure progress as loc()/lof()*100%
Here I used biggest program in JB examples folder - FreeForm code (not sure if it was shpped with JB) If it does not exist, put path to some big text (or BASIC) file.
fformj261006.bas file size is 146164 [############################### ]
fname$="fformj261006.bas" open fname$ for input as #1 fsize= lof(#1) print fname$;" file size is ";fsize
t0=time$("ms") while not (eof(#1)) i=i+1 line input #1, a$ 'goto [skip] pos=loc(#1) r=pos/fsize r1=int(40*r) r2=40-r1 locate 1, 2 'print i,pos, r print "[";left$("###########################################################", r1);space$(r2);"]" [skip] wend
close #1 t1=time$("ms") print "Read ";i;" lines" print "Time taken, ms: ";t1-t0
|
|