Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Show progress

Status
Not open for further replies.

DaPhil

Technical User
Jun 24, 2011
6
DE
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.

François Jacq
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top