I'm trying to pass a single element of an array of hashes, but all I'm getting is zeros. Below are snippets of the code in question. The button is a Tk Widget. I assume I have something wrong with the way I'm either passing the AoH element or the way I've bound it to the button widget, but I can't seem to find the problem. I need to bind the AoH element so that any changes made on the screen by the user are recorded in the element itself so that when they hit the button, the changed value is sent. Perhaps, I'm making this too difficult. See the comments in the code....


<do some DBI stuff>

my @row;
my $count = 0;
my @AoH;
my $id;
my %status = (
    0 => 'Pending',
    1 => 'Initiate Send',
    2 => 'Will NOT be Sent',
    3 => 'Sent'
);

$f1->destroy() if Tk::Exists($f1);
$f1 = $p1_top_frame->Frame->pack(-side => 'top', -expand => 0, -fill => 'none');


while (@row = $sth->fetchrow_array()) {
    $count ++;
    $id = $row[0];

    #save all data from database records in an array of hashes
    $AoH[$count]{id} = $row[0];
    $AoH[$count]{ssn} = $row[1];
    $AoH[$count]{name} = $row[2];
    $AoH[$count]{begindate} = $row[3];
    $AoH[$count]{enddate} = $row[4];
    $AoH[$count]{permit} = $row[5];
    $AoH[$count]{iris_begindate} = $row[6];
    $AoH[$count]{transstatus} = $row[7];

### The following button sends the correct value for $id, but zero for $AoH[$count]{transstatus}

print "$row[7]\n";
my $b1 = $f1->Button(-text => 'Go',
-command => [\&update_record, $id,
$AoH[$count]{transstatus}])->grid(-column => 1,
-row => $count);


### Bind the variable to the array of hashes element so that changes to the radio
### buttons effectively change the value of the AoH element.


foreach (qw/0 1 2/) {
my $r1 = $f1->Radiobutton(-text => $_,
-value => $_,
-variable => \$AoH[$count]{transstatus})->grid(-column => ($_ + 2),
-row => $count);
}


my $t1 = $f1->ROText(-height => 1, -width => 9)->grid(-column => 5, -row => $count);
my $t2 = $f1->ROText(-height => 1, -width => 30)->grid(-column => 6, -row => $count);
my $t3 = $f1->ROText(-height => 1, -width => 10)->grid(-column => 7, -row => $count);
my $t4 = $f1->ROText(-height => 1, -width => 10)->grid(-column => 8, -row => $count);
my $t5 = $f1->ROText(-height => 1, -width => 10)->grid(-column => 9, -row => $count);
my $t6 = $f1->ROText(-height => 1, -width => 10)->grid(-column => 10, -row => $count);


    $t1->insert('end', $row[1]);
    $t2->insert('end', $row[2]);
    $t3->insert('end', $row[3]);
    $t4->insert('end', $row[4]);
    $t5->insert('end', $row[5]);
    $t6->insert('end', $row[6]);
}

-Mike


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to