Help translating C++ to FWH

Help translating C++ to FWH

Postby James Bott » Fri Nov 07, 2008 7:34 am

I am still trying to access an exposed COM object from FWH (xHabour and Borland). I have some sample C++ code. Can anyone help translate for use in FWH?

The COM object has been installed and registered.

Regards,
James

Code: Select all  Expand view
EPSTIPNet::_ChargeNowPtr ptr("EPSTIPNet.gutil.Forms.ChargeNow");
   ptr->init();
   ptr->put_PM(EPSTIPNet::PAYMENTMODE_PayNow);
   ptr->put_CM(EPSTIPNet::CHARGEMODE_Sale);
   ptr->Show();
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Antonio Linares » Fri Nov 07, 2008 8:05 am

James,

You can compile a C++ module and link the resulting OBJ to your application, as C and C++ are compatible.

To access C from C++ (to use [x]Harbour extend system) you have to declare the header files as extern "C":
Code: Select all  Expand view
extern "C" {
    #include <hbapi.h>
};
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Fri Nov 07, 2008 8:09 am

As a example, you can do:
Code: Select all  Expand view
extern "C" {
#include <hbapi.h>
};

#include ...C++ header files...

HB_FUNC( TEST )
{
   EPSTIPNet::_ChargeNowPtr ptr("EPSTIPNet.gutil.Forms.ChargeNow");
   ptr->init();
   ptr->put_PM(EPSTIPNet::PAYMENTMODE_PayNow);
   ptr->put_CM(EPSTIPNet::CHARGEMODE_Sale);
   ptr->Show();
}
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby James Bott » Fri Nov 07, 2008 2:56 pm

Antonio,

I am not clear on what you are saying. Should your example be compiled as a PRG by FWH, or as a C file by Borland?

When I try to compile it as a PRG, I get a "syntax error at 'EXTERN.'"

How do I know which header files to include?

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby James Bott » Fri Nov 07, 2008 3:26 pm

Antonio,

I am making some progress! This code now works:

Code: Select all  Expand view
   oCharge:= CreateObject("EPSTIPNet.gutil.Forms.ChargeNow")
   oCharge:init()


Any ideas on how to translate these lines?

Code: Select all  Expand view
   ptr->put_PM(EPSTIPNet::PAYMENTMODE_PayNow);
   ptr->put_CM(EPSTIPNet::CHARGEMODE_Sale);
   ptr->Show();


Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Enrico Maria Giordano » Fri Nov 07, 2008 5:00 pm

Code: Select all  Expand view
oCharge:put_PM(PAYMENTMODE_PayNow)
oCharge:put_CM(CHARGEMODE_Sale)
oCharge:Show()


You have to search the values for PAYMENTMODE_PayNow and CHARGEMODE_Sale in the include files or in the docs of your COM object.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Antonio Linares » Fri Nov 07, 2008 5:07 pm

James,

good news :-)

if you are able to manage from PRG level, as an OleAuto object, then it is much easier
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby James Bott » Fri Nov 07, 2008 5:21 pm

Enrico,

Would manifest constants only apply when used with FWH, or would they be needed with VB.NET, C#, and/or C++ too?

I cannot find any include files in the SDK files, nor is there any mention of them in the docs.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Enrico Maria Giordano » Fri Nov 07, 2008 6:05 pm

PAYMENTMODE_PayNow and CHARGEMODE_Sale are not manifest constants. They are probably enum data values inside EPSTIPNet class.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby James Bott » Fri Nov 07, 2008 6:12 pm

Enrico,

>PAYMENTMODE_PayNow and CHARGEMODE_Sale are not manifest >constants. They are probably enum data values inside EPSTIPNet class.

OK, but I don't know what that means. How do I solve the problem?

As I guess you can tell, I know nothing about programming in C++.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Enrico Maria Giordano » Fri Nov 07, 2008 6:19 pm

You can't invent their values just as you can't invent manifest constants values. Sorry, I don't know where to find them. Probably they come directly from the .NET platform after the installation of the class module.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby James Bott » Fri Nov 07, 2008 6:22 pm

Enrico,

Is the situation that other languages don't need these values, but with FWH we do? If other languages do need them, then how do they get them?

Is there some tool to allow us to get those values?

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Enrico Maria Giordano » Fri Nov 07, 2008 6:32 pm

James Bott wrote:Enrico,

Is the situation that other languages don't need these values, but with FWH we do?


No, any language need all the values it manage.

James Bott wrote:If other languages do need them, then how do they get them?


Probably they are provided directly by the platform (.NET) after the installation of the class module. .NET is different from Win32.

James Bott wrote:Is there some tool to allow us to get those values?


Probably yes but I know nothing about .NET tools, sorry. And I'm not sure you can use that class in Win32 if it is written for .NET.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby James Bott » Fri Nov 07, 2008 11:53 pm

Here is some more positive news. I am able to get this code to run.

Code: Select all  Expand view
   oCharge:= CreateObject("EPSTIPNet.gutil.Forms.ChargeNow")
   oCharge:init()
   //oCharge:put_PM(PAYMENTMODE_PayNow)
   //oCharge:put_CM(CHARGEMODE_Sale)
   oCharge:Show()


A form quickly displays then vanishes, but at least this indicates that I am successfully instantiating the object. Now if I can just figure out the proper syntax and values for the two statements commented out.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Antonio Linares » Sat Nov 08, 2008 12:08 am

James,

>
PAYMENTMODE_PayNow
CHARGEMODE_Sale
>

Make a search for them everywhere in the code and header files. They have to be there, somewhere.

They seem related to that specific COM object, not with .NET
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 50 guests