For Programmers: Free Programming Magazines  


Home > Archive > Scheme > September 2006 > Updating and displaying values in-place on a screen









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Updating and displaying values in-place on a screen
Förster vom Silberwald

2006-09-05, 8:01 am

Hello: Is that possible: I want a counter, lets say from 1 to 100,
which appears on the screen and counts and being displayed "in-place".

I tried print, write, display, but with no avail because the result
looks as follows, either: 1 2 3 4 5 etc. or

1
2
3
4
etc.

But I want the counter similar to a digital clock so to speak.

Thanks,
Schneewittchen

Jens Axel Søgaard

2006-09-05, 8:01 am

Förster vom Silberwald skrev:
> Hello: Is that possible: I want a counter, lets say from 1 to 100,
> which appears on the screen and counts and being displayed "in-place".
>
> I tried print, write, display, but with no avail because the result
> looks as follows, either: 1 2 3 4 5 etc. or
>
> 1
> 2
> 3
> 4
> etc.
>
> But I want the counter similar to a digital clock so to speak.


I believe the answer depends on the terminal.

The general idea is to

1. print the number
2. print a carriage return
3. go to 1.

However, if the terminal handles carriage return as a linefeed,
you need to print backspaces instead (or perhaps ^W).

--
Jens Axel Søgaard
int2k@gmx.net

2006-09-05, 7:02 pm

"F=F6rster vom Silberwald" <chain_lube@hotmail.com> writes:

> Hello: Is that possible: I want a counter, lets say from 1 to 100,
> which appears on the screen and counts and being displayed "in-place".
>
> I tried print, write, display, but with no avail because the result
> looks as follows, either: 1 2 3 4 5 etc. or
>
> 1
> 2
> 3
> 4
> etc.
>
> But I want the counter similar to a digital clock so to speak.


Jens is right. You just have to figure out the right escape sequences
for your terminal. I found a snippet of Python code which should help
with that [1]. Based on that, I wrote a toy Lisp program and it
worked in my XTerm. BTW, thanks for asking this question: I've been
wanting to do this myself for a couple of days now but I gave up the
first time I tried :-)


Greetings
Wolfram

Footnotes:=20
[1] <http://www.demonseed.net/~jp/code/ansi.py>

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com