Okay,
Tye, I'll post it. I hope this helps. I'll try to explain the problem more in depth. I have two optionmenus and I want them to interact -- one of them contains directories, the other contains files (certain files connected to that directory).
I created a callback on the option menu that holds the directory, but apart from other problems during testing yesterday, doday I'm getting an error message: Can't use string "string here" as a HASH ref. Here's the code, some things, of course, taken out.
sub generate_options {
...
opendir(DIR,$_[0]->{base});
my @subdirs = grep /[Tt][Ss]\d+/, readdir(DIR);
closedir(DIR);
...
my $nb = $mw->NoteBook->grid;
...
for(1..$_[0]->{conds}) {
$page->[$_-1] = $nb->add("Page$_", -label => "Condition $_")
}
for(1..$_[0]->{conds}) {
...
my $dom = $page->[$_-1]->Optionmenu(
-variable => \$info->{subdir}->[$_-1],
-options => [@subdirs],
);
my $fom = $page->[$_-1]->Optionmenu(
-variable => \$info->{file}->[$_-1],
-options => get_files
($_[0]->{base},\@subdirs, 0),
);
# This here is where I get into trouble: $info->{subdir}...
# is spitting out hash ref error described above
$dom->configure(-command =>
sub { $fom->configure(-options =>
get_files($_[0]->{base},$info->{subdir}->[$_-1])) });
my $b = $page->[$_-1]->Button(
-text => "Set",
-command => [\&record, { info => $info, indx => $_-1 }
+],
);
...
$dom->grid( $fom );
...
}
...
}
sub get_files {
opendir(DIR,$_[0] . '\\' . $_[1]->[$_[2]]);
my @files = grep /.txt$/, readdir(DIR);
closedir(DIR);
return [@files];
}