#include <stdinc.h> int progress(double dcpusec, string format, ... )
If stderr has been redirected to a file, no progress is reported.
It is
the users control to make sure the string length does not descrease, since
pieces of the previous string would still be visible. This means a string
like
progress(0.0,"Done %d/%d",i,n);is not a good idea if is decreasing, and it would be better to write
progress(0.0,"Done %3d/%d",i,n);instead.
There are currently two ways to call progress, by cpu time used,
e.g.
do { progress(10.0,"Working on line %3d",n); n = do_something(); } while (n>0);or under full control of the user, as show in this example:
while (n-- > 0) { if (n%100) progress(0.0,"Still %3d to go",n); do_something(); }You can also use progress to take your own actions:
do { if (progress(10.0,0)) dprintf(1,"Working on line %3d\r",n); n = do_something(); } while (n>0);
30-jun-04 created PJT 1-nov-04 changed return type from void to int PJT