Printing to one x-y co-ord

D

Default

any way i can accomplish this? the initial print never seems to work,
untill there is another command after the initial print. (\n <stdin> etc..)

#!
@numbers = (1..10);
foreach $number (@numbers)
{ print "$number";
print "\b\b \b\b";
}
 
D

Default

Accomplish what?

Yea nothing comes out on the screen. What it is is..

Would like to print a character to the screen.

Then backspacer over that character and print a different character
in its place.

sorry i thought the code was self explanitory.
 
J

Jürgen Exner

any way i can accomplish this? the initial print never seems to work,
untill there is another command after the initial print. (\n <stdin>
etc..)

#!
@numbers = (1..10);
foreach $number (@numbers)
{ print "$number";
print "\b\b \b\b";
}

I am guessing you are looking for Curses, but it is quite difficult to tell
because your description is somewhat lacking in clarity.

jue
 
W

William Herrera

any way i can accomplish this? the initial print never seems to work,
untill there is another command after the initial print. (\n <stdin> etc..)

#!
@numbers = (1..10);
foreach $number (@numbers)
{ print "$number";
print "\b\b \b\b";
}

Either your buffering is keeping output away, or the computer is working so
fast it's erasing your numbers before you see them.


Try:

#!/usr/bin/perl -w
# always use strict during development
use strict;
# turn output buffering off
$| = 1;

my @numbers = (1..10);
foreach my $number (@numbers)
{ print "$number";
# pause to see things
sleep 1;
print "\b\b \b\b";
}

<<<<<<<<<<<<
 
D

Default

I am guessing you are looking for Curses, but it is quite difficult to tell
because your description is somewhat lacking in clarity.

jue

Hmmm curses ok, never heard of it.. ill check that out thanks.
See i just want to print something then run a time consuming function,
then backspace over what was just printed, so that i can print something new
in the same place on the screen as the previously printed char.
 
D

Default

# turn output buffering off

Ahh very cool, didn't know that trick.
# pause to see things
sleep 1;

Yes! ive been looking for a built in pause like function.
I've been using <STDIN> to create pauses. That sleep command is very
helpfull indeed, thank you very much.

Ahh yes and not only all that.. your solution works :)
It was the output buffering setting.
Thanks
 
W

William Herrera

Ahh very cool, didn't know that trick.


Yes! ive been looking for a built in pause like function.
I've been using <STDIN> to create pauses. That sleep command is very
helpfull indeed, thank you very much.

Ahh yes and not only all that.. your solution works :)
It was the output buffering setting.
Thanks


You're welcome. BTW, normally when doing this sort of thing you should erase
and then write, not write and erase, ie

loop: {
print "\b\b\ \b\b\$number";
do stuff;
redo loop;
}
 
J

Jürgen Exner

Hmmm curses ok, never heard of it.. ill check that out thanks.
See i just want to print something then run a time consuming function,
then backspace over what was just printed, so that i can print
something new in the same place on the screen as the previously
printed char.

Yep, you are looking for the Curses module.
Keep in mind that many output devices don't support a backspace or the
backspace may have a totally different meaning on them (tapes, braile or
voice readers, TTYs, paper printers, sockets or pipes, ...).
Therefore you need to use the proper action for each device. The Curses
module provides an abstract interface for each action if supported by that
device.

jue
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top