briannz556 has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.
  • Comment on How to find the selected radio button in a Loft GUI

Replies are listed 'Best First'.
Re: How to find the selected radio button in a Loft GUI
by GrandFather (Saint) on Jun 13, 2007 at 23:10 UTC
      Yes, I could supply code but what I'm after is a snippet of an idea to follow. I was wondering if there was a way in perl to do something like: for (7..14) { if ($win-> rb{$_}-> Checked()) { ... indicate found and exit loop ... } } New to perl so not sure what to put for the test condition for the for loop. rb{$_) is just something to indicate my thoughts on what I want. Does that make sense? Cheers

        I'd either put the radio button objects into and array or hash then loop using either:

        for (7..14) { if ($buttons[$_]->Checked ()) { ... indicate found and exit loop ... } }

        or

        for my $key (keys %buttons) { if ($buttons{$key}->Checked ()) { ... indicate found and exit loop ... } }

        depending on what you are trying to achieve.


        DWIM is Perl's answer to Gödel
Re: How to find the selected radio button in a Loft GUI
by briannz556 (Beadle) on Jun 14, 2007 at 03:56 UTC
    Found a solution:
    use Win32::GUI(); use Win32(); use Win32::GUI::Loft::Design(); ... # window exists called AddUser which has 8 radio # buttons named: rb7, rb8, ... rb14 $win = $Win32::GUI::Loft::window{AddUser} for (7..14) { my $rb = "rb$_"; if ($win-> $rb-> Checked()) { ... found selected radio button ... }; last; };
    Thanks for anyone who gave me advice.

      You've got a bug: the last statement should be inside the inner if block.