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
Export a variable from C to Clipper
Export a variable from C to Clipper
Last edited by jgayoso on Thu Aug 28, 2014 1:38 pm, edited 1 time in total.
Re: Export a variable from C to Clipper
Code: Select all
/* 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.!
Try FWH. You will enjoy it's simplicity and power.!
Re: Export a variable from C to Clipper
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
The idea is to simulate:
use mitabla
?micampo
how come:
fMiFuntion()
?myvar
where myvar is defined in fmifunction public or static
bpd2000 wrote:Code: Select all
/* 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
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Export a variable from C to Clipper
Jorge,
As I answered you by email that this code is what you need:
As I answered you by email that this code is what you need:
Code: Select all
# 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