I've attached an example of the test script. For some reason the orginal post wouldn't send when the script was cut&pasted into the web email client.
-Craig -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Craig Dayton Sent: Thursday, August 15, 2002 5:33 PM To: [EMAIL PROTECTED] Subject: Proper setting for Event Handle Ref I've been attempting to get the statement below to work without much success. The 'onreadystatechange' is documented as being a reference to an event handler function. $xmlDOC->{onreadystatechange} = &$subREF; When the script below is executed, the following output is generated. I've tried annoymous sub too. If anyone could push me into the right direction to solve the problem, I be very grateful. Thanks, Craig = output generated COMPLETED Win32::OLE(0.1502) error 0x80020005: "Type mismatch" in PROPERTYPUT "onreadystatechange" at C:\Utopia\scripts\perl\msxml40_dev\589x\chapter02\async_test.pl line 15 === end of output _______________________________________________ Perl-Win32-Admin mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
I've been attempting to get the statement below to work without much success. The 'onreadystatechange' is documented as being a reference to an event handler function. $xmlDOC->{onreadystatechange} = &$subREF; When the script below is executed, the following output is generated. I've tried annoymous sub too. If anyone could push me into the right direction to solve the problem, I be very grateful. Thanks, Craig = output generated COMPLETED Win32::OLE(0.1502) error 0x80020005: "Type mismatch" in PROPERTYPUT "onreadystatechange" at C:\Utopia\scripts\perl\msxml40_dev\589x\chapter02\async_test.pl line 15 === end of output # the script use strict; use warnings; use Win32::OLE; my $str = <<EOF; <rootOfAllEvil> <cause>money</cause> <needs>more money</needs> </rootOfAllEvil> EOF my $xmlDOC = Win32::OLE->new('MSXML2.DOMDocument.4.0') or die "couldn't create"; my $subREF = \&printWarning; #print "ref($subREF)\n"; $xmlDOC->{async} = "True"; # disable/enable $xmlDOC->{onreadystatechange} = &$subREF; # Type Library is: # [id(0x00000044), propput, helpstring("register a readystatechange event handler")] # void onreadystatechange([in] VARIANT rhs); # my $boolean_Load = $xmlDOC->LoadXML($str); sub printWarning { my $state = $xmlDOC->{readyState}; ACTION: { if ($state == 1) {print "Loading\n"; last ACTION;}; if ($state == 2) {print "Loaded\n"; last ACTION;}; if ($state == 3) {print "INTERACTIVE\n"; last ACTION;}; if ($state == 4) {print "COMPLETED\n"; last ACTION; }; } Win32::Sleep(50); };