perlquestion
mikasue
Fellow Monks,
I am trying to display a checklist in a perl Tk program i'm writing. I am having trouble with the Tk::Checkbutton. When I use the following code the checkbuttons do not show up. If I make the arrays into single scalars the checkboxes show up but when I check 1 they all are checked because it's only 1 value for all. So I think I need an array to hold each checkbutton and an array to hold each checkbutton value.
<br>
Please tell me what i'm doing wrong. Thanks!
<code>
my $x = 1; #index for table rows
my $t=0; #index for checkbuttons and values
my @checkboxvalue; #array to hold the checkutton values for each checkbox
my @checkbox; #array to hold the checkbuttons for each row
foreach my $m (@unpaidbills)
{
$checkbox[$t]= $bill_table->Checkbutton(-variable=>\$checkboxvalue[$t]);
$bill_table->put($x,0, $checkbox[$t]);
$bill_table->put($x,1, $m->{bill_name});
$bill_table->put($x,2, "\$$m->{bill_amountdue}");
$bill_table->put($x,3, "$main::month\/$m->{bill_datedue}\/$main::year");
$bill_table->put($x,4, "\$$m->{bill_amountpaid}");
$bill_table->put($x,5, $m->{bill_datepaid});
@paymethods = BPP::PAYMETHODS->retrieve($m->{bill_paymethod});
$bill_table->put($x,6, map{$_->{paymethod_desc}}@paymethods);
my $paybill = $bill_table->Button(-text=>'Submit',
-command=>sub{ if ($checkboxvalue[$t] == 1){
&BillPaymentScreen($m->{bill_name}, $m->{bill_amountdue}, $m->{bill_datedue}, $m->{bill_id}, $tltop) }
else { print "checkbox not paid"} }#end sub
)->pack;
$bill_table->put($x,7, $paybill);
$x++;
}#end foreach loop
</code>
<b>Update> I get the following error:
<code>Use of uninitialized value in numeric eq (==) at BPP/BILL.pm line 148.</code> Which is this line:
<code>if ($checkboxvalue[$t] == 1 </code>