What I am trying to do is use the events that are defined in Win32::Gui. In my script I query a list and dump them into a ListView. Once they are in the ListView I want to be able to click on an element in the ListView and have its detail display in a Textfield. In order to do this I need to use the follow event:

ItemClick(ITEM) Sent when the user selects an item in the ListView; ITEM specifies the zero-based index of the selected item.

so in order to get the desired results I have to create a subroutine for every item in my ListView. When I code it up statically it works.

sub ResultView_ItemClick(2) { $Display->results->Text(${$List{2}}{message}); }
However when I use :
my $code = "sub ResultView_ItemClick($count) { $Display->results->Text +(${$List{$count}}{message});}"; eval $code;
when I am building my list whenever I click on an element I generate an error. When I run the code it seems that the GUI::Dialog reconizes that I created the subs but it throws an error "Undefined subroutine &main::ResultView_ItemClick"

In reply to Re: Dynamic Subroutines? by Anonymous Monk
in thread Dynamic Subroutines? by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.