Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

printing perl at a specific point of the screen

Status
Not open for further replies.

KARLB

Technical User
Apr 4, 2002
29
US
Hi everyone,

Basically, i want to be able to create a bit of a gui interface for a few of my control scripts i have.

I used to be able to display things at a location in shell scripting by echo "[^23;23H HERE WE GO" - which must be wrong, cos it doesnt work any more, but my intention is to use perl to do the controlling and therefor want to be able to print things in a nice mannor. Maybe looking at the report method and printing to screen instead of a file?

Hmm, any help will be much apprieciated :)

KB.
 
There's a module that I think might help. Later at work I'll dig up more info, but I think it's called Term::Cap

It's part of the Term(inal) suite of modules. You can do all kinds of cool things with them, including cursor positioning.

--jim
 
Of course, the hacky cop-out method is to clear the screen and use lots of print "\n"; to get enough blank lines on the page - a sort of manual placement of your printouts...

Not ideal I know, but it works good enough to make your screen look more readable...
 
not only that iceman, but it's accepting input at locations accross the screen. :)


like:



DATE-----------------TIME
options
options
options
INPUT
(blah blah)
||||||||||||||||||||||||||

so it looks nice :)
 
#!c:/Perl/bin/perl -w
use strict;

my @slaves = (
"Graton,Bob,6451324,321,44",
"Strap,Jack,6447553,399,43",
"Simpsons,Homer,6567489,421,40",
);

foreach (@slaves) {
show_slaves($_);
}
exit;

sub show_slaves {
my($nom,$prenom,$slavenum,$horaire,$heures) = split(',', $_[0]);
my $fullname;
$fullname = sprintf("%s %s", $prenom, $nom);
printf("%6d %-20s %6.2f %3d %7.2f\n", $slavenum, $fullname, $horaire, $heures, ($horaire * $heures));
}

# this should get u started ---------------------------------------
wmail.jpg


someone knowledge ends where
someone else knowledge starts
 
neversleep,

Tried the method you suggested, and it looked good. But i still dont really kow how to alter the positioning on the screen.

I used to be able to specify the number of characters down, and accross. Are you doing the same wiht the % operator?

kb.

Sleipnir214, i want not to rely on modules if i can help it. Reason is, i am currently pre-writing things on a remote server, till i get my network up at home.

 
any opportunity/interest in using Tk? 'hope this helps

If you are new to Tek-Tips, please use descriptive titles, check the FAQs, and beware the evil typo.
 
check out the Curses.pm module or PerlVision.pm (check speling please). gives access to the ncurses or curses libraries.
 
Take advantage of muliplying strings in perl for repitition.

for example

my $colsep = 16;
my $inittab = " "x5;
print $inittab, "Date ", '-'x$colsep, " Time\n";
print $inittab, "Jan 2", ' 'x$colsep, "10:30\n";
print $inittab, "Feb 4", ' 'x$colsep, "4:45\n";
print $inittab, "|"x25,"\n";
print "Enter a date/time option\n";
print $inittab,"> ";
my $option = <STDIN>;

And do you see how repetitive the above is?
That is just asking for me to write a printrow() subroutine that does the formatting and prints.

printrow($column1,$myseparator,$column2);

The only thing that you can't do with this is have printing below where you are accepting input. For that you will have to use one of the modules suggested above like Curses.

jaa

 
goBoat, what's tk?

I guess there's no easy way to do this. :)

no worries.

Thanks everyone!!!! looked around, but the interfaces for program langs now-adays seem to be loosing the GUI touch.

Maybe it's the Cobol & CICS scenario? One for the processing, and one for the front end?

Maybe a perl front end??

Karlb.

 
#!perl -w
# look in your computer
# at \Perl\eg\Tk
# tk is a graphic interface to perl
# try this simple example
use Tk;
my $main = new MainWindow;
$main->minsize( qw(500 500));
$main->title(&quot;the title&quot;);
$main->configure(
-background => 'lightgrey'
);
MainLoop(); ---------------------------------------
wmail.jpg


someone knowledge ends where
someone else knowledge starts
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top