FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour returning a wchar_t variable back to harbour function
Posts: 990
Joined: Thu Nov 17, 2005 05:49 PM
returning a wchar_t variable back to harbour function
Posted: 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.

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: returning a wchar_t variable back to harbour function
Posted: Wed May 24, 2023 03:19 AM
This is how FWH returns Wide Strings.
Code (fw): Select all Collapse
//also include
#include <fwh.h>  // fwh\include folder
//
LPWSTR cWideStr;
//
//
fw_retWide( cWideStr );
//
Regards



G. N. Rao.

Hyderabad, India
Posts: 990
Joined: Thu Nov 17, 2005 05:49 PM
Re: returning a wchar_t variable back to harbour function
Posted: 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 (fw): Select all Collapse
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.
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: returning a wchar_t variable back to harbour function
Posted: Wed May 24, 2023 01:15 PM
Even in this case
Code (fw): Select all Collapse
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
Posts: 990
Joined: Thu Nov 17, 2005 05:49 PM
Re: returning a wchar_t variable back to harbour function
Posted: Wed May 24, 2023 08: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,

Continue the discussion