tags:

views:

179

answers:

1

hi i want to store textfield data in a variable but my code is not working here is my code

use Win32::GUI qw<>;

my $W1 = Win32::GUI::Window->new(
 -name  => "W1",
 -title => "First Window",
 -pos   => [ 100, 100 ],
 -size  => [ 300, 200 ],
);

$W1->AddButton(
 -name => "ButtonW1",
 -text => "Enter Chipname",
 -pos  => [ 87, 100 ],
 #-ok  => 1,
);

 $W1->AddTextfield(
  -name    => "chipfield",
  -left    =>  20,
  -top     =>  40,
  -width   => 250,
  -height  => 20,
   #  -prompt => ["Mix ",30],
  );

$W1->Show();
Win32::GUI::Dialog();
exit(0);


sub W1_Terminate { return -1; }

sub ButtonW1_Click {
    my $chipname = $W1->chipfield->Text();
    print $chipname;
}

please help me where is problementer code here

A: 

Looks like a Buffering problem. Add $|=1; before the print $chipname; statement and everything will be fine like so:

my $chipname = $W1->chipfield->Text();
$|=1;
print $chipname;

Or do what axeman suggested by changing

print $chipname;

to

print $chipname,"\n";

You might also want to take a look at this article: Suffering from Buffering?

Mike
you are right your solution working fine for me but it is give me an error "Can't call method "STORE" on an undefined value during global destruction."this error comes when i close my W1 window after google searchnow i am using $chipfield_name->GetLine(0);that is working fine for mee and not giving "Can't call method "STORE" on an undefined value during global destruction."type of error.thanks for your reply :)
amit
@amit, you're welcome :) the code works and exits fine on my computer (ActiveState Perl 5.10.0 WinXP SP3) without the "Can't call method STORE" error. And yes GetLine(0) can also get the job done.
Mike