FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveLinux / FiveDroid (Android) Export a variable from C to Clipper
Posts: 170
Joined: Sat Aug 07, 2010 11:36 PM
Export a variable from C to Clipper
Posted: Tue Aug 26, 2014 05:59 PM

Hearing, as I can export a variable from a routine application of C to Clipper

I want to do the same thing:

USE MYTABLE
聽聽聽聽聽聽聽聽聽聽聽 ? MYCAMPO1

but:
聽聽聽聽聽聽聽聽聽聽聽 fMyFunc_C ()
聽聽聽聽聽聽聽聽聽聽聽 ? MYCAMPO1

where:

Pragma BEGINDUMP

HB_FUNC (fMyFunc_C)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 {
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 char MYCAMPO1 = 'HELLO';
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 }

Pragma ENDDUMP

That fMyFunc to invoke () function is initialized and recognize the variable MYCAMPO1

Posts: 153
Joined: Tue Aug 05, 2014 09:48 AM
Re: Export a variable from C to Clipper
Posted: Thu Aug 28, 2014 01:08 PM
Code (fw): Select all Collapse
/* C贸digo Harbour */
REQUEST HB_GT_WIN_DEFAULT
Function Main()
? Hola()
WAIT
RETURN NIL
/* C贸digo C */
#pragma BEGINDUMP
#include <windows.h>
#include "hbapi.h"
HB_FUNC( HOLA )
{
hb_retc( "Hola Mundo" );
}
#pragma ENDDUMP
Regards, Greetings



Try FWH. You will enjoy it's simplicity and power.!
Posts: 170
Joined: Sat Aug 07, 2010 11:36 PM
Re: Export a variable from C to Clipper
Posted: Tue Sep 02, 2014 01:36 PM
That's not what I want to do:

The idea is to simulate:

use mitabla
?micampo

how come:

fMiFuntion()
?myvar

where myvar is defined in fmifunction public or static





bpd2000 wrote:
Code (fw): Select all Collapse
/* C贸digo Harbour */
REQUEST HB_GT_WIN_DEFAULT
Function Main()
? Hola()
WAIT
RETURN NIL
/* C贸digo C */
#pragma BEGINDUMP
#include <windows.h>
#include "hbapi.h"
HB_FUNC( HOLA )
{
hb_retc( "Hola Mundo" );
}
#pragma ENDDUMP
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Export a variable from C to Clipper
Posted: Wed Sep 03, 2014 09:56 AM
Jorge,

As I answered you by email that this code is what you need:

Code (fw): Select all Collapse
# pragma BEGINDUMP 

#include <hbapi.h>

char * pszChar = "";

HB_FUNC (FMI_C) 
{
   if( hb_pcount() > 0 ) // cambiar el contenido de la variable
   {
      if( pszChar )
         hb_xfree( pszChar )

      pszChar = ( char * ) hb_xgrab( strlen( hb_parc( 1 ) ) + 1 );
      strcpy( pszChar, hb_parc( 1 ) );
   }
   else   // obtener el valor de la variable
      hb_retc( pszChar );
} 

# pragma ENDDUMP
regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion