Re: How to get an OLE array of objects?



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

.



Relevant Pages

  • Re: How to get an OLE array of objects?
    ... This is not Perl. ... Are you thinking of PHP, ... Assuming @nodes does contain an array of hashes, ... documentation again, I think you're right, the properties of an OLE ...
    (comp.lang.perl.modules)
  • Re: How to get an OLE array of objects in Perl?
    ... OLE side you probably want a VARIANT with the following ... safe array in Perl is beyond me, ... VARIANT for the method to fill in. ... of other OLE objects and iterate through them, ...
    (microsoft.public.win32.programmer.ole)
  • Re: NorthWind Database, cant view images
    ... In the Northwind datatabase are Ole bytes array included. ... To get the images you need an offset of 78 bytes. ... (data type: image). ...
    (microsoft.public.dotnet.languages.csharp)
  • How to get an OLE array of objects in Perl?
    ... I posted it over in a Perl ... I have an OLE object with a method that takes an parameter (a ... What I'd like to do is to get that array ... of other OLE objects and iterate through them, ...
    (microsoft.public.win32.programmer.ole)
  • Re: Help a beginner - function with pointer ...
    ... that's a syntax error ... it has been converted to type float*. ... To an extent array notation can be replaced by ... int main ...
    (comp.lang.c)