FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour give pointer in dll
Posts: 357
Joined: Thu Nov 02, 2006 06:53 PM
give pointer in dll
Posted: Mon Jul 07, 2008 06:06 PM

how may I give pointer as parameter to function in DLL

p1,p2 - pinter
err:=_OWersja(p1,p2)

...
...

???
declare DLL_TYPE_BYTE _OWersja(DLL_TYPE_LPCSTR CFILE1, DLL_TYPE_LPCSTR CFILE2) in WinIP.Dll

best regards

kajot
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
give pointer in dll
Posted: Mon Jul 07, 2008 06:15 PM

Kajot,

strings are automatically managed as pointers (their addresses is supplied, not their content).

For numbers you have to supply them by reference using @

If the function is not working as expected, its a good idea to access it using C code instead of using DLL FUNCTION, just to locate where the problem may come from. Just implement a C wrapper using pragma BEGINDUMP ... ENDDUMP. There are many examples in these forums

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 357
Joined: Thu Nov 02, 2006 06:53 PM
give pointer in dll
Posted: Mon Jul 07, 2008 06:31 PM

any samples

best regards

kajot
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
give pointer in dll
Posted: Wed Jul 09, 2008 11:17 PM
Here you have a working example that shows how strings are managed as pointers:
#include "FiveWin.ch"

function Main()

   local cIn := "Hello world!"
   local cOut := Space( Len( cIn ) )

   Test( cIn, cOut )

   MsgInfo( cOut )

return nil

#pragma BEGINDUMP

#include <hbapi.h>

HB_FUNC( TEST )
{
   strcpy( hb_parc( 2 ), hb_parc( 1 ) );
   strupr( hb_parc( 2 ) );
}   

#pragma ENDDUMP
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 357
Joined: Thu Nov 02, 2006 06:53 PM
give pointer in dll
Posted: Thu Jul 10, 2008 07:01 PM

thans
I get error

Missing prototype for 'strupr'

best regards

kajot
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
give pointer in dll
Posted: Thu Jul 10, 2008 07:19 PM

include <hbapi.h>

char * strupr( char * );

...

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 357
Joined: Thu Nov 02, 2006 06:53 PM
give pointer in dll
Posted: Thu Jul 10, 2008 08:33 PM

next error

unresolved external symbol '_strupr'

best regards

kajot
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
give pointer in dll
Posted: Thu Jul 10, 2008 10:45 PM

What C compiler are you using ?

Here it works fine using Borland C 5.5

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 357
Joined: Thu Nov 02, 2006 06:53 PM
give pointer in dll
Posted: Fri Jul 11, 2008 04:49 AM

I am usingv
xHarbour Compiler build 1.0.0 (SimpLex)
Copyright 1999-2007, http://www.xharbour.org http://www.harbour-project.org/

best regards

kajot
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
give pointer in dll
Posted: Fri Jul 11, 2008 07:12 PM

Both Harbour and xHarbour generate a C output file that has to be compiled with a C compiler.

Are you using Borland or Microsoft C compiler to compile the output .C ?
Are you using xHarbour commercial ?

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 357
Joined: Thu Nov 02, 2006 06:53 PM
give pointer in dll
Posted: Sat Jul 26, 2008 05:57 AM

yes, I am using commercial

best regards

kajot
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
give pointer in dll
Posted: Sat Jul 26, 2008 08:17 AM
Kajot,

Then add this code to the PRG:
#pragma BEGINDUMP

#include "string.h"
#include "ctype.h"

char * strupr( char * string )
{
   char c, * p = string;

   while( ( c = * p )  != '\0' )
      * ( p++ ) = _toupper( c );

   return string;
}

#pragma ENDDUMP
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 357
Joined: Thu Nov 02, 2006 06:53 PM
give pointer in dll
Posted: Sun Jul 27, 2008 08:53 AM

thanks

I got worning

missing prototype for '_toupper'

best regards

kajot
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
give pointer in dll
Posted: Sun Jul 27, 2008 08:58 AM
Try this one:

char _toupper( char );

#pragma BEGINDUMP 

#include "string.h" 
#include "ctype.h" 

char _toupper( char );

char * strupr( char * string ) 
{ 
   char c, * p = string; 

   while( ( c = * p )  != '\0' ) 
      * ( p++ ) = _toupper( c ); 

   return string; 
} 

#pragma ENDDUMP
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 357
Joined: Thu Nov 02, 2006 06:53 PM
give pointer in dll
Posted: Sun Jul 27, 2008 09:05 AM

I change
toupper(c)

and is OK

but I got worning in

declare DLL_TYPE_BYTE _OWersja(DLL_TYPE_LPCSTR cfile1, DLL_TYPE_LPCSTR cfile2) in WinIP.Dll

syntax error: "parse error at 'CFILE1'"

best regards

kajot