Re: overwrite output to screen; unix vs windows [message #80633] |
Wed, 27 June 2012 15:21  |
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   |
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 #80646 is a reply to message #80642] |
Wed, 27 June 2012 09:59   |
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   |
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 #80674 is a reply to message #80661] |
Tue, 26 June 2012 17:23   |
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  |
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.
|
|
|