I have a loop that processes a text file. I have a progress bar that should display the progress of the routine - Im seting the gadget state inside the loop, but the progress bar gadget doesn't seem to update until the loop finishes.
I guess this is something to do with event processing and window refresh but I can't wotk it out. I've done a search and tried a couple of things with delay() and windowevent() but to no avail...
Kale wrote:AHA! IIRC 'ReadString()' reads the entire file to a string NOT a single line! so the progressbar is updated all in one go after the entire file is read because '( Loc() / Lof() ) * 100' = 100%. I think your best bet is use 'ReadData()' then process this string for CRLF's for your lines.
??
This is what the manul says about ReadString()
PureBasic Manual wrote:
Read a string on the current opened file until an 'End Of Line' character is found (Unix and DOS file formats are supported).
So this command reads from the file until a EOL char (Dos format = chr(13)+chr(10), UNIX format = chr(10)) is found and puts what was read upto that character into the string..
ReadString() is working as per the manual. One of my source files is 500K and I doubt that PB's string routines would let me load that into 1 string. Besides, the logic of the routine wouldn't allow it and it's working fine in all other respects.
I must say I'm surprised that as of this post 80 people have looked at this problem and there doesn't seem to be a solution. Surely the main use for a progress bar is as I'm trying to use it. ie in a 'long' routine to give the user an indication that the app hasn't just locked up.
Hasn't anyone else tried to use it this way?
I'm sorry if I'm coming over all stressed. Yes I need to chill out! 8O
I Wonder if there's an API to force a repaint of the window / gadget. I seem to remember doing something like that in VB... :roll:
;...
progress_f.f = Loc()/Lof()*100
; maybe you need to store this in an intgerer again to get
; proper float->integer transformation, you can try without.
progress.l = progress_f
SetGadgetState(#Gadget_1, progress)
While WindowEvent()
Wend
; ...
Thanks pupil. If I had any sense I'd have tried setting the progress bar to some intermediate values in the routine or debugged the value I was setting it to...