This HTML automatically generated with rman for NEMO
Table of Contents

Name

progress - write progress strings

Synopsis


#include <stdinc.h>
int progress(double dcpusec, string format, ... )

Description

progress optionally prints out a user-controlled formatted string to stderr, automatically terminated with the carriage-return (\r) symbol, so it overwrites the previous string. The return value if set to 1 if progress should be reported. If the format string is set to 0, no output is done.

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);

See Also

dprintf(3NEMO) , warning(3NEMO) ,

Author

Peter Teuben

History


30-jun-04    created     PJT
1-nov-04    changed return type from void to int    PJT


Table of Contents