Re: How to get an OLE array of objects?
- From: "Paul Lalli" <mritty@xxxxxxxxx>
- Date: 18 Aug 2006 03:57:37 -0700
kingskippus@xxxxxxxxx wrote:
I'm really scratching my head over this. I have an OLE object with a
method that takes an [out] parameter that is an array of other OLE
objects. What I'd like to do is to get that array of other OLE objects
and iterate through them, printing out a property from each one. I
don't know that much about OLE objects, can someone please help? I've
been Googling for a couple of hours and feel like I'm close, but I
can't find anything for that last little bit.
Here's what I need using semi-pseudocode that I know won't work right:
use Win32::OLE;
my $tree = Win32::OLE->new( 'Tree.Component' );
my @nodes = array();
This is not Perl. Are you thinking of PHP, perhaps? To declare an
array, you simply say:
my @nodes;
# GetNodes is a method of TreeComponent that is defined like this:
# int GetNodes([out] TreeNode[])
# where TreeNode is another OLE object type
$tree->GetNodes(\@nodes); # This doesn't work...
What do you mean by "doesn't work"? Did that give you a syntax error?
Run-time error? Or are you just assuming that it "didn't work" based
on later code?
for $node (@nodes) {
print $node{Name}."\n"; # Name is a property of TreeNode objects
Are you using strict and warnings? If not, turn them on. Here, you're
trying to access a hash named %node, rather than a hashref named $node.
Assuming @nodes does contain an array of hashes (or objects), this
should be:
print $node->{Name} . "\n";
Paul Lalli
.
- Follow-Ups:
- Re: How to get an OLE array of objects?
- From: kingskippus
- Re: How to get an OLE array of objects?
- References:
- How to get an OLE array of objects?
- From: kingskippus
- How to get an OLE array of objects?
- Prev by Date: Re: Net::SFTP / Net::SSH::W32Perl strange debug messages?
- Next by Date: Re: How to get an OLE array of objects?
- Previous by thread: How to get an OLE array of objects?
- Next by thread: Re: How to get an OLE array of objects?
- Index(es):
Relevant Pages
|