comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Printing to command line without a new line
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Printing to command line without a new line [message #78220 is a reply to message #78219] Wed, 02 November 2011 14:23 Go to previous messageGo to previous message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
On 11/2/11 1:19 PM, jasmeervirdee@gmail.com wrote:
> On Nov 2, 6:48 pm, David Fanning<n...@dfanning.com> wrote:
>> jasmeervir...@gmail.com writes:
>>> I have a fairly simple question.
>>> My code takes a fair amount of time to run and I would like
>>> it to display a percentage number which updates to the
>>> command line without starting a new line.
>>
>>> So using print one usually does:
>>
>>> for i=0, 100-1, 1 do print, i, '%'
>>
>>> but this creates a long list of numbers. How can I stop a newline
>>> being created by the print command
>>
>>> I hope this is clear. Does anyone know how to do this?
>>
>> http://www.idlcoyote.com/fileio_tips/lfsuppress.html
>>
>> Like this:
>>
>> IDL> for i=0, 15 do print, i, format='((x, I0),$)'
>> 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
>>
>> Cheers,
>>
>> David
>>
>> --
>> David Fanning, Ph.D.
>> Fanning Software Consulting, Inc.
>> Coyote's Guide to IDL Programming:http://www.idlcoyote.com/
>> Sepore ma de ni thui. ("Perhaps thou speakest truth.")
>
> Hi,
>
> Thanks for the response.
>
> It wasn't quite what I was looking for. This prints all the numbers in
> the for loop
> on a single line but what I want is the previous number to disappear
> and
> be replaced by the new number, so that I have one number which is
> constantly updated.
>
> Cheers
>
>

If you are on a terminal that supports ANSI escape sequences, i.e., not
the Workbench, then you can use the following:

esc = string(27B)

for i = 0, 100 do begin
print, esc + '[4D' + esc + '[K', format='(A, $)'
print, i, format='(I3, "%", $)'
wait, 0.1
endfor

I've put the code for this example in a main-level program that you can
run with:

IDL> .run mg_cl_update_demo

The code is here:

http://michaelgalloy.com/wp-content/uploads/2011/11/mg_cl_up date_demo.pro

Mike
--
Michael Galloy
www.michaelgalloy.com
Modern IDL, A Guide to Learning IDL: http://modernidl.idldev.com
Research Mathematician
Tech-X Corporation
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Math errors tracked! To a built-in library...
Next Topic: Alert IDL

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 13:53:14 PDT 2025

Total time taken to generate the page: 0.00366 seconds