To be more specific, I'm using wodFtpDLXCom, a COM object for working with FTP developed by WeOnlyDo. When an FTP server returns an error, e.g. when a client tries to list the content of a nonexistent directory, the object throws an exception that can be successfully caught in PB and handled. The problem is that apparently error handling is implemented by the object differently for FTP and SFTP: for FTP, the specific error code can be queried via the object property LastError and the error text via the ErrorText method, e.g. "40550 - Requested action not taken. File unavailable (e.g. file not found, no access)"; for SFTP, however, these property and method return a generic error "30031 - Server returned an error:" for any error with no further details.
WeOnlyDo support suggested to write a handler for the object's event Done that receives error code and text. I tried it with VBScript and indeed saw "Server returned an error: No such file or folder". Unfortunately, I haven't been able to do the same in PB, and the support do not know PowerBuilder so they cannot help.
The object provides an alternative way of notification (https://www.weonlydo.com/FtpDLX/Help/wodFtpDLX-Fast-notifications-interface.html). Quoting, "wodFtpDLXCom can use fast notification interface instead of firing events. This means that each time wodFtpDLXCom needs to fire an event, it will call your implementation of the event instead." To use this, a custom object that implements the needed interface IwodFtpNotify should be assigned to the Notification property of wodFtpDLXCom. The link provides an example in VB.
This Notification property is shown as having the OLEObject data type in PB IDE object browser, so I created a descendant of OLEObject, declared all procedures that are part of IwodFtpNotify and tried to assign its instance to the Notification property:
iole_child = create n_ole_child
li_res = iole_child.ConnectToNewObject("WeOnlyDo.wodFtpDLXCom.1")
iole_child.Notification = iole_child
This throws a runtime error "Error accessing external object property notification". I also tried to assign a window instance with the same result. The only line that didn't throw a runtime error was:
iole_child.Notification = create n_ole_child
But my implementation of IwodFtpNotify_Done in n_ole_child was never called. I also tried calling SetAutomationPointer:
iole_child.Notification = create n_ole_child
iole_child.Notification.SetAutomationPointer( iole_child)
But this call throws "Null object reference".
So I am wondering how I can assign an object implementing the interface to a property of a COM object that has the OLEObject data type.