overwrite output to screen; unix vs windows [message #80675] |
Tue, 26 June 2012 16:00 |
jdeast
Messages: 5 Registered: June 2012
|
Junior Member |
|
|
I'd like to print a status that runs inside a for loop and gets overwritten after each iteration, so as not to flood the screen. In unix, you can do it like this:
(unix, good)
IDL> for i=1, 5 do print, i, format='("' + string(13b) + '",i3,"% complete",$)' & print, ''
5% complete
which prints " 1% complete", the "string(13b)" is a carriage return, but the "$" tells it to continue on the same line, so it is promptly overwritten by " 2% complete" and so on until it finishes at " 5% complete", all on the same line. The final print, '' is outside the loop and just resets the IDL prompt when it's done. In this simple example, it happens so fast you only see the final output.
However, the same line, executed in windows, prints it on 5 separate lines:
(windows, bad):
IDL> for i=1, 100 do print, i, format='("' + string(13b) + '",i3,"% complete",$)' & print, ''
1% complete
2% complete
3% complete
4% complete
5% complete
Is there a way to get the unix behavior in windows?
Thanks,
Jason
|
|
|