[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

print output in textarea

Posted on 2004-09-23
3
Medium Priority
?
398 Views
Last Modified: 2008-02-01
Hi..
i would like to know how can i print the output generate by the sub-condition onto the
text area of the perl tk gui.

This is how i create my text area using perl tk:

#Create Scrollbar widget and setting it's entity
 
$xscroll = $frame7->Scrollbar(-orient => 'horizontal');
$yscroll = $frame7->Scrollbar(-orient => 'vertical');

# Create text widget($text)and setting it to uneditable & other entity  
my $text = $frame7->ROText('-width'=>70,'-height'=>20,
-xscrollcommand => ['set', $xscroll],
-yscrollcommand => ['set', $yscroll]);
$xscroll->configure(-command => ['xview', $text]);
$yscroll->configure(-command => ['yview', $text]);
$xscroll->pack(-side => 'bottom', -fill => 'x');
$yscroll->pack(-side => 'right', -fill => 'y');
$text->pack(-side=>'top', -fill => 'both', -expand => 1);

This is the sub-condition i use to crunch data and save the crunched data into text files.
sub condition1()
{

#Get entry
      $mac=$f->get('active');
        $dev=$d->get('active');
        $datef=$entry2->get;
        $datet=$entry3->get;
      $file=$entry->get;

#connect to the database
my $dbh = DBI->connect('dbi:mysql:rvsi','','', {RaiseError=>1, PrintError=>1});

# Extract the data from database
my $d = $dbh->selectall_arrayref("select qin, qout, yield, reject FROM yield WHERE date BETWEEN '$datef' AND '$datet'");
    print ("Daily Yield Report Summary for '$dev' between '$datef' to '$datet'\n\n");
    print ("Qin\t", "Qout\t", "Yield\t", "Reject\n");

# Print out all the array catch  
foreach my $r(@$d) {
    print join("\t", @$r), $/;
}

#print the dotted line
print "-"x60, $/;

#Do the calculation
my $t = $dbh->selectrow_arrayref("select sum(qin), sum(qout), ((sum(qout)/sum(qin))*100), sum(reject) FROM yield WHERE date BETWEEN '$datef' AND '$datet'");
print join("\t", @$t), $/;

die "$file already exists\n" if -f $file;
open FILE, ">$file" or die "Can not create $file $!\n";

#print the sums at the top of the file, separated by tabs
print FILE "Daily Yield Report Summary\n";
print FILE "Device: '$dev'\n";
print FILE "Date: '$datef' to '$datet'\n\n";
print FILE "Qin\t", "Qout\t", "Yield\t", "Reject\n";
foreach my $r(@$d) {
print FILE join("\t", @$r), $/;}

#write the other arrays in tab-separated columns underneath the sums
 print FILE  "-"x60, $/;
 print FILE join("\t", @$t), $/;

close(FILE);
}
0
Comment
Question by:TPoly
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 5

Expert Comment

by:ZiaTioN
ID: 12145469
replace:
print join("\t", @$r), $/;

with:
$text ->insert("end",  "$r\n");

You can do your own formatting as far as the \t (tab) goes. Maybe something like " $r .= "\t"; before the insert() function.
0
 
LVL 5

Accepted Solution

by:
ZiaTioN earned 750 total points
ID: 12145516
For future reference you can check out a text editor I wrote in perl/Tk at the following link: http://www.perlskripts.com/cgi-bin/showscript.cgi?pEdit=1

I coded a ton of Tk functions and commented pretty well so you may be able to find what you are looking for in this code. If you want to download this app and use it visit the site directly (www.perlskripts.com) and navigate to the scripts ection. There are some support file you will need to grab in order to make this program complete. The first link I gave is strictly for the source code.
0
 

Author Comment

by:TPoly
ID: 12157413
it is unable to print the output on the text area.

beside, i also want to know to how to print a "file created successful"

or

die "$file already exists\n" if -f $file;
open FILE, ">$file" or die "Can not create $file $!\n";

in the textarea

thanks
0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question