1. Andrew Davis
  2. PowerBuilder
  3. Monday, 15 January 2018 16:05 PM UTC

Hi Can anyone help

I have a oleobject dll that I need to accesS - I have the following code

 

OLEObject  objDEPHandler
string strError
long numResultCode
integer li_port,li_ret
 
li_port=1
 
objDEPHandler = create OLEObject
 
if objDEPHandler.connecttonewobject("MPITengineLite.DEPHandler")<0 then
messagebox("DEPHandler","Cant create MPITengineLite.DEPHandler")
destroy objDEPHandler
RETURN
end if
 
objDEPHandler.deviceid=1
 
objDEPHandler.open(li_port) // it crashes here saying error calling external function open
 
// this is the definition
 

Open

method Open

Syntax:

Open(ComPort)

Parameters:

Data Type

Name

Direction

Necessity

(I2)

ComPort

[IN]

required

Return:

(EMPTY)

regards

 

Andrew

Accepted Answer
Andrew Davis Accepted Answer Pending Moderation
  1. Tuesday, 16 January 2018 07:43 AM UTC
  2. PowerBuilder
  3. # Permalink

Hi all

I have found the problem - i added a ref in the open(ref li_port) and it all works now 

thank your for your suggestions - I will add the try catch - this may help in the futur

regards

Andrew

Comment
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Monday, 15 January 2018 20:08 PM UTC
  2. PowerBuilder
  3. # 1

Hi Andrew;

   My suggestion would be to first wrap the PowerScript code that deals with the OLE interaction inside a TRY..CATCH block. The nice thing about that approach is that when the OLE/OCX interaction fails, the Exception object often contains more detailed information about the exact failure.

Food for thought.

Regards ... Chris

Comment
There are no comments made yet.
Chris Harmon Accepted Answer Pending Moderation
  1. Monday, 15 January 2018 23:57 PM UTC
  2. PowerBuilder
  3. # 2

Besides the try and catch you could create a custom oleobject. Then you could see more extended error information in the error events either through the debugger or placing code in the events.

Chris

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.