Im having a problem which is seeminly driving me nutty..I am currently writing an application
in which uses the Curses::Forms module, in order to dynamically change menu style, content, size
I must make a call to a localized sub routine
my $form = Curses::Forms->new({ 'Y' => 1, 'X' => 0,
'LINES' => $LINES - 2, 'COLS' => $COLS });
$form->add(
{ 'type' => 'list_box', 'name' => 'Orders',
'ypos' => 0, 'xpos' => 25, 'cols' => ($COLS - 27),
'lines' => 8, 'title' => ' Orders ', 'list' => ["blah"
+,"blah2"] },
{ 'type' => 'txt_field', 'name' => 'Status',
'ypos' => 10, 'xpos' => 25, 'cols' => $COLS - 27,
'lines' => $LINES - 14, 'title' => ' Status ',
'content' => '(no record selected)' },
{ 'type' => 'list_box', 'name' => 'Menu',
'ypos' => 0, 'xpos' => 0, 'cols' => $COLS - 57,
'lines' => $LINES - 4, 'title' => ' Menu ', 'list' =>
+[],
},
);
$form->tab_order(qw( Orders Menu));
$form->bind(
["Orders", "[ \n]", "Mod_Oth", \&get_menu, "Me
+nu"],
["Orders", "[\n]", "Nxt_Wdgt"],
["Menu", "[ \n]", "Mod_Oth", \&do_somthing, "S
+tatus"],
["Menu", "[hH]", "Mod_Oth", \&get_help, "Menu"
+],
["Orders", "[rR]", "Mod_Oth", \&refresh_win, "
+Orders"]
);
$form->set_defaults ( DEF_FUNC => \&clock);
$form->activate();
This is how the form is set up. Now lets use the routine &do_somthing, which is where
my problem is coming from, whenever on the "Menu" form the enter key is pressed, it calls
the sub routine do_somthing. do_somthing is local and looks like this
local *do_somthing = sub {
my $list_ref = shift;
my $menu_ref = shift;
my $status_ref = shift;
my $selected;
my $blah;
my $selected_num = $$menu_ref{'selected'};
my ($id, $menu) = split(/ /,$$menu_ref{'title'});
$selected = $$menu_ref{'list'}{$selected_num};
print "$selected\n";
$selected =~ s/\s+$//g;
if ($selected eq "VIEW CONFIGURATION") {
$blah = &external_subroutine($id);
$$status_ref{"content"} = $blah;
}
elsif {
$$status_ref{"content"} = "HRMM";
}
};
.....
.....
..... outside this whole block of code
sub external_subroutine {
my $id = @_; # IM THINKING THIS MAY BE THE PROBLEM
$id =+ 10;
return $id;
}
so the code takes in references from what was passed to it from the bind(), and Im trying to
change the content of the "status" window to the contents of the return value of the &external_subroutine
Ok no problem right? It works great the FIRST time you press the menu item "view configuration",
but after that all my references seem to be overwritten or just have disappeared so If I select
another menu item I dont get the elsif it just doesnt do anything. I know this HAS to do somthing
with localized subroutines and calling external sub routines will overwrite the current references
or somthing wierd like that...I dont know, if anyone can help it would be of great help to me. Or you can just -- me becuase
I was way to confusing in explaining my problem
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.