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

I'm using Win32::OLE with the events turned on.
I make a call to a control (dll) for data and the control will fire an event when data is ready. The data returned is an array of recordset: here is a snippet:
use Win32::OLE qw( EVENTS); use Data::Dumper ; package MyEvents; sub OnDataReady2 { my ($Obj, @Args) = @_; ... }
The recordset is converted to basically a hash but I can't seem to actually get the data. When I do a data dump it runs out of memory. Anyone know anything about this?

Replies are listed 'Best First'.
Re: Handling returned data from a OLE object.
by traveler (Parson) on Feb 20, 2003 at 16:26 UTC
    In my experience when Dumper runs out of memory dumping a Microsoft data structure, it is because the structure is recursive: it contains references to itself. I deal with this by telling Dumper to only dump 1 or 2 levels.

    HTH, --traveler

      Your right it seems to point back to itself. The actual problem is that where I expect the data to be is not there. Here is the output of the dump:
      $VAR2 = [ bless( { 'Properties' => bless ( { 'Count' => 102, 'Item' => undef }, 'Win32::OLE'), 'AbsolutePosition 'ActiveConnection 'BOF' => 0, 'Bookmark' => '1' 'CacheSize' => 1, 'CursorType' => 3 'EOF' => 0, 'Fields' => bless ( { 'Count' => 5, 'Item' => undef }, 'Win32::OLE'), 'LockType' => 1, 'MaxRecords' => 0 'RecordCount' => 'Source' => '', 'AbsolutePage' => 'EditMode' => 0, 'Filter' => 0, 'PageCount' => 1, 'PageSize' => 10, 'Sort' => '', 'Status' => 0, 'State' => 1, 'CursorLocation' 'MarshalOptions' 'DataSource' => $VAR2->[0], 'ActiveCommand' = 'StayInSync' => 1 'DataMember' => ' 'Index' => '' }, 'Win32::OLE' ) ];
      I expect the data to be in the Item keys but they are undef. Has anyone worked the returned data from an OLE event?
Re: Handling returned data from a OLE object.
by meetraz (Hermit) on Feb 20, 2003 at 18:11 UTC
    Win32::OLE objects are strange.. I think they use a combination of properties/methods which are the same, which confuses you if you look at the Data::Dumper output. In other words, even though "Item" looks like a property, it's really a method.

    To get data back from the recordset, you do this:

    while (! $Obj->{EOF}) { print $Obj->fields("FieldOne")->{Value}, "\n"; print $Obj->fields("FieldTwo")->{Value}, "\n"; print $Obj->fields("FieldThree")->{Value}, "\n"; $Obj->MoveNext(); }
      Thanks alot you're right Item was a method and :
      print $Obj->Fields->Item(0)->Value, "\n";

      gave me the data. thanks again.
Re: Handling returned data from a OLE object.
by meetraz (Hermit) on Feb 20, 2003 at 17:41 UTC
    That looks like an ADO recordset. What are you trying to do with the returned object?
      That's right it is a recordset but I can't seem to get the data from it. The Item keys I think should point to an array containing the actual data but it seems to be undefined.