I'm probably going to mess this up, but I think what's happening is:
You use \$map_fields[$cnt2] to store the location of (pointer to) the space occupied by $map_fields[$cnt2], but I think that the dereferencing of the array is happening first, so you store a reference to a string which is the value stored at $map_fields[$cnt2].
I think the solution is to initially store references to scalars in @map_fields, then always manipulate them as references, as in:This code seems to do what you want, though I didn't learn the grid placment manager or make a DB to truly try it out. --Bob Niederman, http://bob-n.comuse Tk; $mw = new MainWindow(-title=>'mapp'); $pg = $mw->Frame; @map_fields = \(qw( A B C D E )); $cnt2 = 0; @file_fieldnames = qw( SHOW COLUMNS FROM lead SKIP ); foreach my $field ( @file_fieldnames ) { $pg->Label(-relief => 'sunken', -width => 15, -text => $field)->pac +k(); my $brb = $pg->BrowseEntry(-variable => ($map_fields[$cnt2]) ); $brb->insert('end', @$dbfields); $cnt2++; $brb->pack(); } my $btn =$pg->Button(-text=>'doit', -command => sub { doit() } ); $btn->pack; $pg->pack(); MainLoop; sub doit { $ifg->{parameter} = '1,2,3,4,5'; my @a = ( split ( ",", $ifg->{parameter} ) ); for ( @map_fields ) { $$_ = shift @a } ; }
All code given here is UNTESTED unless otherwise stated.
In reply to Re: Updating variables in Tk programmes
by bobn
in thread Updating variables in Tk programmes
by jdtoronto
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |