returning a wchar_t variable back to harbour function

returning a wchar_t variable back to harbour function

Postby reinaldocrespo » Wed May 24, 2023 12:08 am

Hello everyone!

Inside a harbour wrapper function I need to declared a variable as wchar_t or HB_WCHAR but I don't know how to return that variable back to calling harbour function. I tried using hb_retc as with any other string but that won't return wide strings. Is there another vm return function I can use to return HB_WCHAR variables?

Thank you,

Reinaldo.
User avatar
reinaldocrespo
 
Posts: 972
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Re: returning a wchar_t variable back to harbour function

Postby nageswaragunupudi » Wed May 24, 2023 3:19 am

This is how FWH returns Wide Strings.

Code: Select all  Expand view
//also include
#include <fwh.h>  // fwh\include folder
//
LPWSTR cWideStr;
//
//
fw_retWide( cWideStr );
//
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: returning a wchar_t variable back to harbour function

Postby reinaldocrespo » Wed May 24, 2023 12:17 pm

Hello Mr. Rao and everyone else;

Your information is valuable to me but this is a different situation.

I'm sorry I should have been more specific. I'm trying to return a c wchar_t variable type from a VM Harbour wrapper c function back to the calling Harbour (clipper) code.

Code: Select all  Expand view

HB_FUNC( OCRFROMFILEUSINGTRANSYM )
{
   TOCRJOBINFO_EG    JobInfo_EG;
   TOCRRESULTSEX_EG* Results = 0;
   long            Status;
   long            JobNo = 0;
   byte            OptionsMask = HB_ISNUM( 3 ) ? hb_parnl( 3 ) : 0x00000000 ;
   long            Orientation = HB_ISNUM( 4 ) ? hb_parnl( 4 ) : TOCRJOBORIENT_AUTO;
   long            ErrorMode   = HB_ISNUM( 5 ) ? hb_parnl( 5 ) : TOCRERRORMODE_LOG ;
   HB_WCHAR        Msg[10240];      //<==Wide string that I later want to return
   char * InputFile = ( char * ) hb_parcx( 1 );   //parm 1 is input file
   FILE*          logfile ;
   time_t         currentTime;
   char timeString[100];


...

   hb_retc( Msg ) ; //  <== this won't work as hb_retc only returns static char * types.    
 


So either the VM has another way to return a wide string back to Harbour or I will have to convert that wide string but that is something I rather not do. On all my wrappers I had ignored wide strings. But now I realize I will have to fix that but wide strings a new to me.

Thank you.
User avatar
reinaldocrespo
 
Posts: 972
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Re: returning a wchar_t variable back to harbour function

Postby nageswaragunupudi » Wed May 24, 2023 1:15 pm

Even in this case
Code: Select all  Expand view
fw_retWide( cMsg )

will work, as long as we are working with Windows OS.
Please try.
You need to include "<fwh.h>"
Or please give me some sample that we can try at our end to test.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: returning a wchar_t variable back to harbour function

Postby reinaldocrespo » Wed May 24, 2023 8:33 pm

Yes, Mr. Rao, it does work.

I followed the header file down into getfile.c and saw how it is being done and why it works. It is a good learning experience for me.

Thank you very much,
User avatar
reinaldocrespo
 
Posts: 972
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 85 guests