Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Perl Misc (http://www.velocityreviews.com/forums/f67-perl-misc.html)
-   -   continous update (print) (http://www.velocityreviews.com/forums/t899245-continous-update-print.html)

Lars Madsen 07-31-2006 11:33 AM

continous update (print)
 

if one e.g . wants to write a countdown one can do this as

$|=1;
....
# some loop
printf "% 4d\r", $count;

where \r then makes sure that we reprint on them same line over and over again.

But what if you want to do this with several lines at once?

I have a data structure with, say, 10 special entries that changes every second,
I would like to have a continous overview if these numbers in the same fashion
as above.

How would one do that?


--

/daleif (remove RTFSIGNATURE from email address)

Lars Madsen 07-31-2006 01:52 PM

Re: continous update (print)
 

> A simple solution is to clear the screen before printing:
>
> my $clear = qx(clear);
>
> while ( 1 ){
> print $clear;
> printf "%s\n",'some text';
> }
>


well yes, besides the fact that the screen flickers a bit, clearing the screen
seems to work.


--

/daleif (remove RTFSIGNATURE from email address)

anno4000@radom.zrz.tu-berlin.de 07-31-2006 03:35 PM

Re: continous update (print)
 
Aukjan van Belkum <aukjan@gmail.com> wrote in comp.lang.perl.misc:
> Lars Madsen wrote:
> >
> >> A simple solution is to clear the screen before printing:
> >>
> >> my $clear = qx(clear);
> >>
> >> while ( 1 ){
> >> print $clear;
> >> printf "%s\n",'some text';
> >> }
> >>

> >
> > well yes, besides the fact that the screen flickers a bit, clearing the
> > screen seems to work.
> >
> >

> Yes it does ... i didn't say it was pretty ... just simple ;-)


Put a delay in the loop and update the screen only once per second or so.
The flicker will get much bettter.

Anno

Lars Madsen 07-31-2006 03:38 PM

Re: continous update (print)
 
es it does ... i didn't say it was pretty ... just simple ;-)
>
>
> Put a delay in the loop and update the screen only once per second or so.
> The flicker will get much bettter.
>
> Anno


I already do that, it looks ok.


--

/daleif (remove RTFSIGNATURE from email address)

Jürgen Exner 08-01-2006 03:22 AM

Re: continous update (print)
 
Lars Madsen wrote:
> if one e.g . wants to write a countdown one can do this as
>
> $|=1;
> ...
> # some loop
> printf "% 4d\r", $count;
>
> where \r then makes sure that we reprint on them same line over and
> over again.
> But what if you want to do this with several lines at once?
>
> I have a data structure with, say, 10 special entries that changes
> every second, I would like to have a continous overview if these
> numbers in the same fashion as above.
>
> How would one do that?


Use the Curses module to position the cursor before each output block.

jue




All times are GMT. The time now is 05:11 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.