Export a variable from C to Clipper

Post Reply
jgayoso
Posts: 170
Joined: Sat Aug 07, 2010 11:36 pm
Location: Chile

Export a variable from C to Clipper

Post by jgayoso »

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
Last edited by jgayoso on Thu Aug 28, 2014 1:38 pm, edited 1 time in total.
User avatar
bpd2000
Posts: 153
Joined: Tue Aug 05, 2014 9:48 am
Location: India

Re: Export a variable from C to Clipper

Post by bpd2000 »

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.!
jgayoso
Posts: 170
Joined: Sat Aug 07, 2010 11:36 pm
Location: Chile

Re: Export a variable from C to Clipper

Post by jgayoso »

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: 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
User avatar
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

Post by Antonio Linares »

Jorge,

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
regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply