On 02.05.2022 21:06, Rick McGuire wrote:
On Mon, May 2, 2022 at 1:19 PM Rony G. Flatscher <rony.flatsc...@wu.ac.at>
wrote:
Currently "samples\ole\adsi\adsi4.rex" looks like:
/*******************************************************************/
/* ADSI Sample 4: */
/* */
/* Using filters with ADSI collections. */
/* */
/*******************************************************************/
ComputerName = value("COMPUTERNAME",,"ENVIRONMENT")
computerObject = .OLEObject~GetObject("WinNT://"||ComputerName)
computerObject~Filter = .array~of("Group","Service")
/* show only objects of type Group and Service: */
do item over computerObject
say item*~class* ":" item~name
end
return 0
Running it via 32-bit Rexx (r12376) yields on my machine:
C:\Program Files (x86)\ooRexx\samples\ole\adsi>bkp\adsi4.rex
Group : Administratoren
... cut ...
Group : System Managed Accounts Group
... cut ...
Service : AdobeARMservice
Service : AESMService
Service : AGMService
Service : AGSService
Service : AJRouter
Service : ALG
Service : AppHostSvc
Service : AppIDSvc
Service : Appinfo
Service : Apple Mobile Device Service
Service : AppMgmt
Service : AppReadiness
Service : AppVClient
Service : AppXSvc
Service : aspnet_state
Service : AssignedAccessManagerSvc
Service : AudioEndpointBuilder
Service : Audiosrv
Service : autotimesvc
Service : AxInstSV
Service : BDESVC
Service : BFE
... cut ...
However, this seems like an error as "item~class" should yield "The OLEObject
class" instead
of the strings "Group" or "Service".
Mark Miesfield added overrides to a number of methods on the OLEObject (copy, class, send, etc.)
class back in 2009 to check if the underlying OLE Object has a matching method name and do the
dispatch as if the method had been overridden.
Thank you, I did not know that!
OLE programs should employ either "item~unknown('class',.array~new)" or
"item~dispatch('class')" to get the message "CLASS" to be transported to
the Windows side.
How can one get at the ooRexx class object in this case ?
The answer for an OLEObject is always going to be The OLEObject class.
Unfortunately this is not always the case anymore!
---
The "class" message gets overridden, if the Windows object possesses a Method named "class", so it
does not answer "The OLEObject class" in such cases. E.g. "item" in adsi4.rex is "an OLEObject",
sending it the message "class" answers with "Group" or "Service", not "The OLEObject class".
(The same is probably also true, if the Windows object implements the methods "copy", "send" or
"start" which would inhibit the usage of the .Object methods "copy", "send" or "start".)
Here a rewritten version of adsi4.rex to inspect the abilities of the first
"item" in various ways:
ComputerName = value("COMPUTERNAME",,"ENVIRONMENT")
computerObject = .OLEObject~GetObject("WinNT://"||ComputerName)
computerObject~Filter = .array~of("Group","Service")
tab="09"x
do item over computerObject
say tab "---> item~class :" pp(item~class) "(-> expected:
'The OLEObject class')"
say tab "---> item :" pp(item)
say tab "---> item~isA(.oleObject) :" pp(item~isA(.oleObject))
say
say tab "---> item~dispatch('class') :"
pp(item~dispatch("class"))
say tab "---> item~unknown('class',.array~new):" pp(item~unknown('class',.array~new)) "(->
""item~unknown('class',.nil)"" does not work anymore)"
say
say tab "---> item~class:.object :" pp(item~class:.object) --
<-- error 98.938
leave
end
::routine pp
return "["arg(1)"]"
The output shows that "item" is "an OLEObject":
C:\Program Files (x86)\ooRexx\samples\ole\adsi>adsi4.rex
---> item~class : [Group] (-> expected: 'The
OLEObject class')
---> item : [an OLEObject]
---> item~isA(.oleObject) : [1]
---> item~dispatch('class') : [Group]
---> item~unknown('class',.array~new): [Group] (->
"item~unknown('class',.nil)" does not work anymore)
14 *-* say tab "---> item~class:.object :"
pp(item~class:.object) -- <-- error 98.938
Error 98 running C:\Program Files (x86)\ooRexx\samples\ole\adsi\adsi4.rex
line 14: Execution error.
Error 98.938: Message search overrides can be used only from methods of the
target object.
Error 98.938 is raised because of trying to get at .Object's method named class.
---
So the question is how to become able to have messages directed sent to .Object in the case the
Windows peer possesses the method causing Mark's overriding to take place?
Another question is how to document this in "winextensions.pdf", e.g. communicating as if OLEObject
had the methods class, copy, send, start (a complete list of such methods, not sure where to find
them) implemented and only forwards them to .Object, if the Windows peer does not have the
respective method implemented. But then how to direct messages in these cases directly to .object if
the programmer has a need to do so?
---rony
_______________________________________________
Oorexx-devel mailing list
Oorexx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oorexx-devel