A
andy
My requirement is as below:
I want a counter of 3 numbers and it will count and keep the last count
as it is.
The second time i open and run this script and press count buttons it
should start counting from the last counter value.
Each time a count button is pressed it should be loged in to a txt file
with date and time.
I have written the script but not able to print the date and time in to
the log file.
The most important thing is that i want to save the last count and the
counter should start from the last saved counter when i run this script
again.
Please go through the script and suggest something.
Thanks in advance.
The below is my script:
#!\c\perl\bin
#######################################################################################
use strict;
#use warnings;
use Tk;
use Win32::Console;
Win32::Console::Free();
my $mw = new MainWindow; # Main Window
my $frm_name = $mw -> Frame() -> pack();
my $But_5 = $mw -> Button(-text=>"Counter of 5", -command
=>\&Addition_5) -> pack();
my $But_10 = $mw -> Button(-text=>"Counter of 10", -command
=>\&Addition_10) -> pack();
my $But_20 = $mw -> Button(-text=>"Counter of 20", -command
=>\&Addition_20) -> pack();
my $Save = $mw -> Button(-text=>" Save ", -command =>\&Save_Resulet)
-> pack();
my $Res;
sub Save_Result
{
$Res=$Res;
#&Saved_Counter;
}
#Text Area
my $txt = $mw -> Text(-width=>45, -height=>8,-background =>
'white',-font => "Arial 11 bold", -foreground => "black") -> pack();
open (fh,">>counter_log.txt") or die "can't open counter_log.txt $!\n";
print fh "###### Started ######\n\n";
MainLoop;
#This is executed when the button is pressed
sub Addition_5
{
print fh "check\n";
print fh `date /t`;
print fh `time /t`;
$Res=$Res+5;
$txt -> insert('end',"The Addition is: $Res\n\n");
print fh "The Addition is: $Res\n";
}
sub Addition_10
{
$Res=$Res+10;
$txt -> insert('end',"The Addition is: $Res\n\n");
print fh `date /t`;
print fh `time /t`;
print fh "The Addition is: $Res\n";
}
sub Addition_20
{
$Res=$Res+20;
$txt -> insert('end',"The Addition is: $Res\n\n");
print fh `date /t`;
print fh `time /t`;
print fh "The Addition is: $Res\n";
}
close(fh);
I want a counter of 3 numbers and it will count and keep the last count
as it is.
The second time i open and run this script and press count buttons it
should start counting from the last counter value.
Each time a count button is pressed it should be loged in to a txt file
with date and time.
I have written the script but not able to print the date and time in to
the log file.
The most important thing is that i want to save the last count and the
counter should start from the last saved counter when i run this script
again.
Please go through the script and suggest something.
Thanks in advance.
The below is my script:
#!\c\perl\bin
#######################################################################################
use strict;
#use warnings;
use Tk;
use Win32::Console;
Win32::Console::Free();
my $mw = new MainWindow; # Main Window
my $frm_name = $mw -> Frame() -> pack();
my $But_5 = $mw -> Button(-text=>"Counter of 5", -command
=>\&Addition_5) -> pack();
my $But_10 = $mw -> Button(-text=>"Counter of 10", -command
=>\&Addition_10) -> pack();
my $But_20 = $mw -> Button(-text=>"Counter of 20", -command
=>\&Addition_20) -> pack();
my $Save = $mw -> Button(-text=>" Save ", -command =>\&Save_Resulet)
-> pack();
my $Res;
sub Save_Result
{
$Res=$Res;
#&Saved_Counter;
}
#Text Area
my $txt = $mw -> Text(-width=>45, -height=>8,-background =>
'white',-font => "Arial 11 bold", -foreground => "black") -> pack();
open (fh,">>counter_log.txt") or die "can't open counter_log.txt $!\n";
print fh "###### Started ######\n\n";
MainLoop;
#This is executed when the button is pressed
sub Addition_5
{
print fh "check\n";
print fh `date /t`;
print fh `time /t`;
$Res=$Res+5;
$txt -> insert('end',"The Addition is: $Res\n\n");
print fh "The Addition is: $Res\n";
}
sub Addition_10
{
$Res=$Res+10;
$txt -> insert('end',"The Addition is: $Res\n\n");
print fh `date /t`;
print fh `time /t`;
print fh "The Addition is: $Res\n";
}
sub Addition_20
{
$Res=$Res+20;
$txt -> insert('end',"The Addition is: $Res\n\n");
print fh `date /t`;
print fh `time /t`;
print fh "The Addition is: $Res\n";
}
close(fh);