Re: Win32::OLE - "Member not found" in PROPERTYPUTREF

Michael Ludwig <[email protected]>
Newsgroups gmane.comp.lang.perl.active-perl
Message-ID <20100819214326.GR852@wladimir>
Hi Jan,

Jan Dubois schrieb am 19.08.2010 um 11:11 (-0700):
> […] The "by value" and "by reference" assignments are implemented by 2
> different COM operation internally: propertyput and propertyputref.
> Normally all OLE properties will implement both, especially if they
> rely on some automated framework to implement their IDispatch
> interface.

Thanks for your great, fabulous explanation!

> You seem to be running into a property that has only implemented
> propertyput but not propertyputref, so the default syntax fails for
> you.  It means the corresponding code in VBscript would fail too:
> 
>     Set xslProc.input = xmlDoc
> 
> and only this one would work:
> 
>     xslProc.input = xmlDoc

It does fail in VBScript indeed:

          \,,,/
          (o o)
------oOOo-(_)-oOOo------
Option Explicit
' See: http://msdn.microsoft.com/en-us/library/ms753809%28VS.85%29.aspx
Dim xslt, xslDoc, xslProc, xmlDoc
Set xslt   = WScript.CreateObject("Msxml2.XSLTemplate.3.0")
Set xslDoc = WScript.CreateObject("Msxml2.FreeThreadedDOMDocument.3.0")
xslDoc.async = false
xslDoc.load "createProcessor.xsl"
If (xslDoc.parseError.errorCode <> 0) Then
  myErr = xslDoc.parseError
  WScript.Echo "You have error " + myErr.reason
Else
  xslt.stylesheet = xslDoc ' "Set" will also work here
  Set xmlDoc = WScript.CreateObject("Msxml2.DOMDocument.3.0")
  xmlDoc.async = false
  xmlDoc.load "books.xml"
  If (xmlDoc.parseError.errorCode <> 0) Then
    myErr = xmlDoc.parseError
    WScript.Echo "You have error " + myErr.reason
  Else
    Set xslProc = xslt.createProcessor
    xslProc.input = xmlDoc ' "Set" will fail here
    xslProc.addParameter "param1", "Hello"
    xslProc.transform
    WScript.Echo xslProc.output
  End If
End If

> It makes a certain amount of sense to force the user to assign a value
> and not an object, but most other OLE objects seem to allow either and
> simply call the default method themselves if they can't deal with an
> object.
> 
> I don't want to dive into indexed properties here, as it does not
> apply to your situation.

Fine, I can wait till I bump into them.

> I would not bother with this typelib stuff, just always use "by
> reference" assignments everywhere, and only when it fails investigate
> if you are running into a limitation of that objects implementation
> and have to use "by value" assignment explicitly.

Excellent, I'm going to follow that route. Thanks once more!

Michael
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.