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

Home » Public Forums » archive » Re: overwrite output to screen; unix vs windows
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: overwrite output to screen; unix vs windows [message #80633] Wed, 27 June 2012 15:21 Go to next message
lecacheux.alain is currently offline  lecacheux.alain
Messages: 325
Registered: January 2008
Senior Member
On 27 juin, 18:59, jde...@gmail.com wrote:
> Thanks for your help everyone.
>
> @David: I just looked at the 12 files and the widgets and it seemed like too much. Did I miss something? Are there 3 lines I can extract from those codes that do this in the terminal? This is just a minor annoyance for a minority of users, and not worth requiring an additional library and adding a GUI to my otherwise command-line only code.
>
> @Gianguido: that routine has the same problem as mine. Works in unix, not in Windows.
>
> @alx: can that be broken up into separate commands which get executed at each cycle in a for loop?
>
> I tried
>
> print, 0, format='(t1,i4,$)' & print, 1, format='(t1,i4,$)' & print
>
> but that doesn't work in unix or windows. This:
>
> print, 0, format='(t1,i4,$,"' + string(13b) + '")' & print, 1, format='(t1,i4,$)' & print
>
> works in unix, but not windows.
>
> Thanks,
> Jason
>
>

I am not aware of "overwrite" format in IDL FORTRAN formats.
But you might achieve your goal by mixing with IDL C-style formats.
For instance, doing the following code in a Windows command window, I
can overwrite on a same output line all the 11 numbers, one per
second.

IDL> .run
- for i=0,10 do begin
- print,i,FORMAT='(%"\b%d",$)'
- wait,1
- endfor
- print
- end
% Compiled module: $MAIN$.
10
IDL>

%" ... " are delimiters for C-style format; \b is the escape code for
backspace.
Please refer to the documentation.

alain.
Re: overwrite output to screen; unix vs windows [message #80636 is a reply to message #80633] Wed, 27 June 2012 12:27 Go to previous messageGo to next message
jdeast is currently offline  jdeast
Messages: 5
Registered: June 2012
Junior Member
I think you're all too right that supporting windows is not a path I want to go too far down. I was just hoping there was a simple fix. Instead, I've kludged it so it limits the number of prints if !version.os_family eq 'Windows'.

Thanks for your help,
Jason

On Wednesday, June 27, 2012 10:52:47 AM UTC-7, David Fanning wrote:
> jdeast@gmail.com writes:
>
>> @David: I just looked at the 12 files and the widgets and it seemed like too much. Did I miss something? Are there 3 lines I can extract from those codes that do this in the terminal? This is just a minor annoyance for a minority of users, and not worth requiring an additional library and adding a GUI to my otherwise command-line only code.
>
> I've never looked at that zip file, but all you
> need is the one progress bar file. All the others
> are test programs.
>
> 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.")
Re: overwrite output to screen; unix vs windows [message #80640 is a reply to message #80636] Wed, 27 June 2012 10:52 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
jdeast@gmail.com writes:

> @David: I just looked at the 12 files and the widgets and it seemed like too much. Did I miss something? Are there 3 lines I can extract from those codes that do this in the terminal? This is just a minor annoyance for a minority of users, and not worth requiring an additional library and adding a GUI to my otherwise command-line only code.

I've never looked at that zip file, but all you
need is the one progress bar file. All the others
are test programs.

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.")
Re: overwrite output to screen; unix vs windows [message #80642 is a reply to message #80640] Wed, 27 June 2012 10:18 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
jdeast@gmail.com writes:

> @David: I just looked at the 12 files and the widgets and it seemed like too much. Did I miss something? Are there 3 lines I can extract from those codes that do this in the terminal? This is just a minor annoyance for a minority of users, and not worth requiring an additional library and adding a GUI to my otherwise command-line only code.

Windows users don't understand command line code. You
might as well give them something they are used to.
Otherwise, you are going to face support nightmares. :-)

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.")
Re: overwrite output to screen; unix vs windows [message #80646 is a reply to message #80642] Wed, 27 June 2012 09:59 Go to previous messageGo to next message
jdeast is currently offline  jdeast
Messages: 5
Registered: June 2012
Junior Member
Thanks for your help everyone.

@David: I just looked at the 12 files and the widgets and it seemed like too much. Did I miss something? Are there 3 lines I can extract from those codes that do this in the terminal? This is just a minor annoyance for a minority of users, and not worth requiring an additional library and adding a GUI to my otherwise command-line only code.

@Gianguido: that routine has the same problem as mine. Works in unix, not in Windows.

@alx: can that be broken up into separate commands which get executed at each cycle in a for loop?

I tried

print, 0, format='(t1,i4,$)' & print, 1, format='(t1,i4,$)' & print

but that doesn't work in unix or windows. This:

print, 0, format='(t1,i4,$,"' + string(13b) + '")' & print, 1, format='(t1,i4,$)' & print

works in unix, but not windows.

Thanks,
Jason
Re: overwrite output to screen; unix vs windows [message #80651 is a reply to message #80646] Wed, 27 June 2012 09:32 Go to previous messageGo to next message
lecacheux.alain is currently offline  lecacheux.alain
Messages: 325
Registered: January 2008
Senior Member
On 27 juin, 01:00, jde...@gmail.com wrote:
> 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
>
>

You can use a combination of T and $ formats:
IDL> print,indgen(10),FORMAT='(10(T1,i4,$))' & print
9

alx.
Re: overwrite output to screen; unix vs windows [message #80656 is a reply to message #80651] Wed, 27 June 2012 09:03 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
jdeast@gmail.com writes:

> Hmmm... that looks like swatting a mosquito with an a-bomb. Surely there's a simpler way, like my working unix example?

Really!? It's three lines of uncomplicated code, compared
to one line of really complicated code. Seems a good trade-
off to me. :-)

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.")
Re: overwrite output to screen; unix vs windows [message #80659 is a reply to message #80656] Wed, 27 June 2012 08:49 Go to previous messageGo to next message
cgguido is currently offline  cgguido
Messages: 195
Registered: August 2005
Senior Member
http://astro.berkeley.edu/~johnjohn/idl.html#COUNTER

For people who don't like A-bombs.


On Wednesday, June 27, 2012 10:37:07 AM UTC-5, jde...@gmail.com wrote:
> Hmmm... that looks like swatting a mosquito with an a-bomb. Surely there's a simpler way, like my working unix example?
Re: overwrite output to screen; unix vs windows [message #80661 is a reply to message #80659] Wed, 27 June 2012 08:37 Go to previous messageGo to next message
jdeast is currently offline  jdeast
Messages: 5
Registered: June 2012
Junior Member
Hmmm... that looks like swatting a mosquito with an a-bomb. Surely there's a simpler way, like my working unix example?
Re: overwrite output to screen; unix vs windows [message #80674 is a reply to message #80661] Tue, 26 June 2012 17:23 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
jdeast@gmail.com writes:

> 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?

Ronn Kling's progress bar is a corker. I love it!

http://kilvarock.com/widgets.htm

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.")
Re: overwrite output to screen; unix vs windows [message #80741 is a reply to message #80633] Sat, 30 June 2012 14:50 Go to previous message
jdeast is currently offline  jdeast
Messages: 5
Registered: June 2012
Junior Member
Excellent, thanks! It doesn't work from the IDLDE interface in windows, but I'll take it.

(Sorry for the late reply, I had given up.)

Jason

On Wednesday, June 27, 2012 3:21:08 PM UTC-7, alx wrote:
> On 27 juin, 18:59, jde...@gmail.com wrote:
>> Thanks for your help everyone.
>>
>> @David: I just looked at the 12 files and the widgets and it seemed like too much. Did I miss something? Are there 3 lines I can extract from those codes that do this in the terminal? This is just a minor annoyance for a minority of users, and not worth requiring an additional library and adding a GUI to my otherwise command-line only code.
>>
>> @Gianguido: that routine has the same problem as mine. Works in unix, not in Windows.
>>
>> @alx: can that be broken up into separate commands which get executed at each cycle in a for loop?
>>
>> I tried
>>
>> print, 0, format='(t1,i4,$)' & print, 1, format='(t1,i4,$)' & print
>>
>> but that doesn't work in unix or windows. This:
>>
>> print, 0, format='(t1,i4,$,"' + string(13b) + '")' & print, 1, format='(t1,i4,$)' & print
>>
>> works in unix, but not windows.
>>
>> Thanks,
>> Jason
>>
>>
>
> I am not aware of "overwrite" format in IDL FORTRAN formats.
> But you might achieve your goal by mixing with IDL C-style formats.
> For instance, doing the following code in a Windows command window, I
> can overwrite on a same output line all the 11 numbers, one per
> second.
>
> IDL> .run
> - for i=0,10 do begin
> - print,i,FORMAT='(%"\b%d",$)'
> - wait,1
> - endfor
> - print
> - end
> % Compiled module: $MAIN$.
> 10
> IDL>
>
> %" ... " are delimiters for C-style format; \b is the escape code for
> backspace.
> Please refer to the documentation.
>
> alain.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: writing equation in IDL
Next Topic: Dropped dimensions?

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

Current Time: Wed Oct 08 15:27:41 PDT 2025

Total time taken to generate the page: 0.00799 seconds