From: Kevin M. <kej...@ho...> - 2009-07-30 07:47:02
|
Hey, Instead of trying to use symbolic references to the objects, one solution would be to store the objects in an array and simply iterate over the array to access the objects. You could also use a hash if you want to access them by name. I've used this method when using TabStrip controls. Here is an example: #creating objects my @objects; foreach(0..4){ push @objects, $parent->AddDateTime->new(-name => "DateTime$_"); } #accessing objects foreach(0..4){ $objects[$_]->SetDateTime(...); } __END__ Hope this helps. Kevin. > From: ki...@ne... > To: per...@li... > Date: Thu, 30 Jul 2009 13:14:48 +1000 > Subject: [perl-win32-gui-users] blessed object dereferencing unusual behaviour... > > Hi, > > I was having a problem with a DateTime object, and I noticed some behaviour > that differs from other Perl programs, so I thought I'd ask here if this is > a bug, and if there's anyway around it. The unusual behaviour is as > follows: > > DB<52> x $datetime1_tab0 > 0 Win32::GUI::DateTime=HASH(0x7b54a54) > '-accel' => 0 > '-handle' => 1705748 > '-name' => 'DateTime1_tab0' > '-type' => 24 > > This is a typical object created by AddDateTime to a window. > > DB<53> x ${datetime1_tab0} > 0 Win32::GUI::DateTime=HASH(0x7b54a54) > '-accel' => 0 > '-handle' => 1705748 > '-name' => 'DateTime1_tab0' > '-type' => 24 > > Same object, but with a bit of syntax sugar difference. > > DB<54> x ${"datetime1_tab0"} > 0 HASH(0x7b87064) > empty hash > > Huh? It's my understanding (and testing this with a couple of other modules > confirms this) that anything with the braces {} gets "evaluated" and if it > returns a valid result, then everything should be fine. > > The reason I'm trying to do it this way is because I have quite a few of > these objects, and I want to create a simple loop to iterate over them, > setting each one to the right time according to my script, but if I can't > substitute "1/2/3" as needed in the variable name, then I'm stuck. > > I've also tried: > > DB<59> $temp = "datetime1_tab0" > > > DB<60> x ${$temp} > 0 HASH(0x7b87064) > empty hash > > DB<61> x $$temp > 0 HASH(0x7b87064) > empty hash > > As you can see, no such luck. I'm completely stumped. Does anyone have any > tips or advice on how to proceed ? > > Thank you. > > > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day > trial. Simplify your report design, integration and deployment - and focus on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > _______________________________________________ > Perl-Win32-GUI-Users mailing list > Per...@li... > https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users > http://perl-win32-gui.sourceforge.net/ _________________________________________________________________ Use Windows Live Messenger from your Hotmail inbox Web IM has arrived! http://windowslive.ninemsn.com.au/article.aspx?id=823454 |