Export a variable from C to Clipper

Export a variable from C to Clipper

Postby jgayoso » Tue Aug 26, 2014 5: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
Last edited by jgayoso on Thu Aug 28, 2014 1:38 pm, edited 1 time in total.
jgayoso
 
Posts: 170
Joined: Sat Aug 07, 2010 11:36 pm
Location: Chile

Re: Export a variable from C to Clipper

Postby bpd2000 » Thu Aug 28, 2014 1:08 pm

Code: Select all  Expand view
/* 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.!
User avatar
bpd2000
 
Posts: 153
Joined: Tue Aug 05, 2014 9:48 am
Location: India

Re: Export a variable from C to Clipper

Postby jgayoso » Tue Sep 02, 2014 1: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: Select all  Expand view
/* 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
jgayoso
 
Posts: 170
Joined: Sat Aug 07, 2010 11:36 pm
Location: Chile

Re: Export a variable from C to Clipper

Postby Antonio Linares » Wed Sep 03, 2014 9:56 am

Jorge,

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

Code: Select all  Expand view
# 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
User avatar
Antonio Linares
Site Admin
 
Posts: 42097
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveLinux / FiveDroid (Android)

Who is online

Users browsing this forum: No registered users and 17 guests