perl_seeker has asked for the wisdom of the Perl Monks concerning the following question:
The user clicks on the 'Print receipt' button and receipt gets printed. But suppose the user wants to print the receipt again and clicks on the button in the same open window a second time, the $receiptno gets updated and the receipt number for the same set of data is printed incorrectly (number +1).Also the same set of data is written to the text file again.my $mw = MainWindow->new; $mw->geometry("500x250"); /*Other stuff*/ $mw->Button(-text=>'OK',-background=>'blue',-command=>\&ok_but)->pack( +-side=>'top',-pady=>2); MainLoop; sub ok_but { $receiptno=40; /*Other stuff*/ $sw->Button(-text=>'Deposit work receipt',-background=>'blue',-command +=>\&deposit)->pack(-side=>'top',-pady=>2); sub deposit{ my $dw = MainWindow->w; $dw->geometry("500x700"); /* Entry boxes and lists where user enters/selects data for receipt generation */ $dw->Button(-text=>'Print receipt',-background=>'blue',- command=>\&d +eposit_fwrite_print)->pack(-side=>'top',-pady=>2); } sub deposit_fwrite_print{ /* Write data to text file and print recipt receipt using Win32::Printer::Direct; */ $receiptno=$receiptno +1; } } End of subroutine ok_but
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl Tk variable update question
by zentara (Cardinal) on Jan 06, 2010 at 11:38 UTC | |
| |
|
Re: Perl Tk variable update question
by graff (Chancellor) on Jan 07, 2010 at 06:20 UTC | |
by perl_seeker (Scribe) on Jan 08, 2010 at 11:45 UTC |