Hi,
I want to print the progress of a subroutine on the command line. But the percentage should be updated in the same line. Right now, the actual percentage done is shown in a new line. How do I do that?
Difficult to do in a portable manner. Try the usual extension $ at the end of a format. This one deletes the termination character(s) but prints the line(s) anyway.
Code:
program test
write(*,"(2a,i2,'%',$)") char(13),"Progress ",25
write(*,"(2a,i2,'%',$)") char(13),"Progress ",75
end program
CHAR(13) is the "Return" character which come back to the first column.
Notice that the "advance='no'" capability of the WRITE statement in F95 could do the job but it depends in fact on the compiler. Indeed, a line is normally printed only when it is completed (i.e. ended by a LF or CRLF termination which is not added precisely because of advance='no').
Another possibility would consist in using ansi.sys and the escape sequences. At last, you could try to clear the windows first.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.