[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Overwriting printings



dominik@astro.uva.nl wrote:
> 
> In article <395214A5.BA0D21B1@mathstat.dal.ca>,
>   simon@mathstat.dal.ca wrote:
> 
> > Is there a way to get IDL to overwrite the previous print output,
> > ratherthan starting a new line? I'm running IDL in Linux..
> 
> the `$' format character disables the automatic newline,
> the character control-k kill the current output line.
> Use something like this:
> 
> for i=1,1000 do begin
>     print,format='(A,A,$)',string(13b),string(i)
> endfor
> print,''   ; terminate the current line
>

I do this sort of thing by printing out the backspace character (8B)
however many times I need to overwrite the last output. This way, my
line title doesn't get smushed. In the following snippet, the XXXX, XXX
of XXX... gets overwritten with the current numbers, but the line title
"Transforming....blah blah" does not:

bksp = MAKE_ARRAY( 20, VALUE = 8B )
PRINT, FORMAT = '( /5x, "Transforming IFG for AIRS channel:", /, "XXXX,
XXX of XXX....", $ )'

begin_channel = 0
end_channel   = n_channels - 1

FOR i = begin_channel, end_channel DO BEGIN

  PRINT, FORMAT = '( a, i4, ", ", i3, " of ", i3, "....", $ )', $
                  STRING( bksp ), analysis[ i ].channel, i + 1,
n_channels

(I'm sure your news reader will truncate the lines at 80 cols, dammit)

I absolutely agree with the original posters comment about code
slow-down vs. psychological benefits. It's like getting stuck in the
subway with no info about why..... yoicks.

paulv
-- 
Paul van Delst           Ph:  (301) 763-8000 x7274 
CIMSS @ NOAA/NCEP        Fax: (301) 763-8545
Rm.202, 5200 Auth Rd.    Email: pvandelst@ncep.noaa.gov
Camp Springs MD 20746