Embedding a 3rd party .dll

Re: Embedding a 3rd party .dll

Postby Antonio Linares » Thu Sep 26, 2013 2:49 pm

Gilbert,

Code: Select all  Expand view

int pascal SepaTools_XMLGetData( char *Data, int *Size );

    HB_FUNC( SEPATOOLS_XMLGETDATA ) // pXml, @nSize --> nRetCode (?)
    {
        int iSize = hb_parni( 2 );

        hb_retni( SepaTools_XMLGetData( ( char * ) hb_parc( 1 ), &iSize ) );
        hb_storni( iSize, 2 );  
    }
 
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42094
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Embedding a 3rd party .dll

Postby Jeanette Panitz » Wed Oct 23, 2013 8:24 am

Hello,

i have still more problems with embedding functions of the .dll.

The function
Code: Select all  Expand view
int pascal SepaTools_GetDTAProtokoll( XMLReadStruct24 *XMLReadStruct, int Fehler, int *First );

retrieves and stores a struct.

The struct
Code: Select all  Expand view

typedef struct  
{  
    char  PmInfoId[35+1];      
    char  AusfDatum[8+1];        
    char  AuftragName[70+1];   
    char  AuftragBIC[11+1];    
    char  AuftragIBAN[35+1];   
    char  AuftragAbwName[70+1]
    char  AuftragCI[35+1];     
    char  EmpfName[70+1];       
    char  EmpfBIC[11+1];         
    char  EmpfIBAN[35+1];      
    char  EmpfAbwName[70+1];   
    char  Purpose[4+1];          
    char  Betrag[12+1];        
    char  EndToEndId[35+1];    
    char  MandatId[35+1];        
    char  MandatDatum[8+1];    
    char  SequenceType[4+1];   
    int   B2B;                   
    int   SammlerAnzahl;       
    char  SammlerSumme[12+1];   
    char  Zweck1[70+1];        
    char  Zweck2[70+1];        
    int   Hinweis[30];         
} XMLReadStruct24;

contains an array of integer "Hinweis". I don't how to handle it. I tried the following

Code: Select all  Expand view

HB_FUNC( SEPATOOLS_GETDTAPROTOKOLL )
{
    int iSize = hb_parni( 3 );

    XMLReadStruct24 aStruct;
    strcpy( aStruct.PmInfoId, ( char * ) hb_parc( 1, 1 ) );
    strcpy( aStruct.AusfDatum, ( char * ) hb_parc( 1, 2 ) );
    strcpy( aStruct.AuftragName, ( char * ) hb_parc( 1, 3 ) );
    strcpy( aStruct.AuftragBIC, ( char * ) hb_parc( 1, 4 ) );
    strcpy( aStruct.AuftragIBAN, ( char * ) hb_parc( 1, 5 ) );
    strcpy( aStruct.AuftragAbwName, ( char * ) hb_parc( 1, 6 ) );
    strcpy( aStruct.AuftragCI, ( char * ) hb_parc( 1, 7 ) );
    strcpy( aStruct.EmpfName, ( char * ) hb_parc( 1, 8 ) );
    strcpy( aStruct.EmpfBIC, ( char * ) hb_parc( 1, 9 ) );
    strcpy( aStruct.EmpfIBAN, ( char * ) hb_parc( 1, 10 ) );
    strcpy( aStruct.EmpfAbwName, ( char * ) hb_parc( 1, 11 ) );
    strcpy( aStruct.Purpose, ( char * ) hb_parc( 1, 12 ) );
    strcpy( aStruct.Betrag, ( char * ) hb_parc( 1, 13 ) );
    strcpy( aStruct.EndToEndId, ( char * ) hb_parc( 1, 14 ) );
    strcpy( aStruct.MandatId, ( char * ) hb_parc( 1, 15 ) );
    strcpy( aStruct.MandatDatum, ( char * ) hb_parc( 1, 16 ) );
    strcpy( aStruct.SequenceType, ( char * ) hb_parc( 1, 17 ) );
    aStruct.B2B = hb_parni( 1, 18 );
    aStruct.SammlerAnzahl = hb_parni( 1, 19 );
    strcpy( aStruct.SammlerSumme, ( char * ) hb_parc( 1, 20 ) );
    strcpy( aStruct.Zweck1, ( char * ) hb_parc( 1, 21 ) );
    strcpy( aStruct.Zweck2, ( char * ) hb_parc( 1, 22 ) );
    aStruct.Hinweis = hb_parni( 1, 23 );
       
       
    SepaTools_GetDTAProtokoll( &aStruct, hb_parni( 2 ), &iSize );
    hb_storni( iSize, 3 );
       
    hb_reta( 23 );
    hb_storc( aStruct.PmInfoId, -1, 1 );
    hb_storc( aStruct.AusfDatum, -1, 2 );
    hb_storc( aStruct.AuftragName, -1, 3 );
    hb_storc( aStruct.AuftragBIC, -1, 4 );
    hb_storc( aStruct.AuftragIBAN, -1, 5 );
    hb_storc( aStruct.AuftragAbwName, -1, 6 );
    hb_storc( aStruct.AuftragCI, -1, 7 );
    hb_storc( aStruct.EmpfName, -1, 8 );
    hb_storc( aStruct.EmpfBIC, -1, 9 );
    hb_storc( aStruct.EmpfIBAN, -1, 10 );
    hb_storc( aStruct.EmpfAbwName, -1, 11 );
    hb_storc( aStruct.Purpose, -1, 12 );
    hb_storc( aStruct.Betrag, -1, 13 );
    hb_storc( aStruct.EndToEndId, -1, 14 );
    hb_storc( aStruct.MandatId, -1, 15 );
    hb_storc( aStruct.MandatDatum, -1, 16 );
    hb_storc( aStruct.SequenceType, -1, 17 );
    hb_storni( aStruct.B2B, -1, 18 );
    hb_storni( aStruct.SammlerAnzahl, -1, 19 );
    hb_storc( aStruct.SammlerSumme, -1, 20 );
    hb_storc( aStruct.Zweck1, -1, 21 );
    hb_storc( aStruct.Zweck2, -1, 22 );
    hb_storni( aStruct.Hinweis, -1, 23 );
}

but I get this error:

Error E2277 sepatool.prg 728: Lvalue required in function HB_FUN_SEPATOOLS_CONVERTCSVTOXML
Error E2342 sepatool.prg 754: Type mismatch in parameter 'iValue' (wanted 'int', got 'int *') in function HB_FUN_SEPATOOLS_CONVERTCSVTOXML

Regards,
Jeanette
With best regards,
Jeanette

http://www.ctosoftware.de/
Jeanette Panitz
 
Posts: 10
Joined: Mon Oct 21, 2013 10:58 am
Location: Germany

Re: Embedding a 3rd party .dll

Postby Antonio Linares » Wed Oct 23, 2013 8:32 am

Jeanette,

You have posted the source code of function SEPATOOLS_GETDTAPROTOKOLL() but the errors that you get are from another function:

Error E2277 sepatool.prg 728: Lvalue required in function HB_FUN_SEPATOOLS_CONVERTCSVTOXML
Error E2342 sepatool.prg 754: Type mismatch in parameter 'iValue' (wanted 'int', got 'int *') in function HB_FUN_SEPATOOLS_CONVERTCSVTOXML


Please post the code for function SEPATOOLS_CONVERTCSVTOXML(), thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42094
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Embedding a 3rd party .dll

Postby Jeanette Panitz » Wed Oct 23, 2013 8:43 am

yes, the same error occurs while compiling function HB_FUN_SEPATOOLS_CONVERTCSVTOXML.

But now the right errors
Code: Select all  Expand view
Error E2277 SepaGetDTAProtocol.prg 101: Lvalue required in function HB_FUN_SEPATOOLS_GETDTAPROTOKOLL
Error E2342 SepaGetDTAProtocol.prg 132: Type mismatch in parameter 'iValue' (wanted 'int', got 'int *') in function HB_FUN_SEPATOOLS_GETDTAPROTOKOLL
With best regards,
Jeanette

http://www.ctosoftware.de/
Jeanette Panitz
 
Posts: 10
Joined: Mon Oct 21, 2013 10:58 am
Location: Germany

Re: Embedding a 3rd party .dll

Postby Antonio Linares » Wed Oct 23, 2013 4:08 pm

Jeanette,

What source code do you have in SepaGetDTAProtocol.prg in lines 101 and 132 ?

I can't know it from your posted code
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42094
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Embedding a 3rd party .dll

Postby Jeanette Panitz » Thu Oct 24, 2013 7:13 am

Antonio,

the sourcecode in line 101 and 132 should retrieve and store the array of integer "Hinweis".

line 101: aStruct.Hinweis = hb_parni( 1, 23 );
line 132: hb_storni( aStruct.Hinweis, -1, 23 );
With best regards,
Jeanette

http://www.ctosoftware.de/
Jeanette Panitz
 
Posts: 10
Joined: Mon Oct 21, 2013 10:58 am
Location: Germany

Re: Embedding a 3rd party .dll

Postby Antonio Linares » Thu Oct 24, 2013 7:40 am

Jeanette,

Hinweis seems to be an array of ints;

int Hinweis[30];

not sure if you have to fill there several values (please review your docs about it) but if you want to fill just the first element of the array then do:

aStruct.Hinweis[ 0 ] = hb_parni( 1, 23 );

hb_storni( aStruct.Hinweis[ 0 ], -1, 23 );

not sure why you have 30 ints array there. Please check your docs about it.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42094
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Embedding a 3rd party .dll

Postby Jeanette Panitz » Thu Oct 24, 2013 8:24 am

Antonio,

for only one value your solution works fine. Thank you. But I have to fill the array with all 30 values.
Now I tried to use a for loop to retrieve 30 values

Code: Select all  Expand view

int k, l;
for ( k = 0; k < 30; k++ ) {
    l = k+1;
    aStruct.Hinweis[k] = hb_parni( 1, 23, l );
}
 

Compiling and linking are successful but the element "Hinweis" is after looping still empty.
Last edited by Jeanette Panitz on Thu Oct 24, 2013 10:33 am, edited 1 time in total.
With best regards,
Jeanette

http://www.ctosoftware.de/
Jeanette Panitz
 
Posts: 10
Joined: Mon Oct 21, 2013 10:58 am
Location: Germany

Re: Embedding a 3rd party .dll

Postby mgsoft » Thu Oct 24, 2013 10:12 am

Hello,

Can you please post the full code?.

Thanks.
Saludos,

Eduardo
User avatar
mgsoft
 
Posts: 422
Joined: Mon Aug 17, 2009 12:18 pm
Location: España

Re: Embedding a 3rd party .dll

Postby Jeanette Panitz » Thu Oct 24, 2013 10:32 am

Hello Eduardo,

it's the same sourcecode like in my earlier post (Wed Oct 23, 2013 8:24 am).
I changed only line 101, so it looks now like that:

Code: Select all  Expand view

typedef struct  
{  
       // ...        
       int   Hinweis[30];          
} XMLReadStruct24;

HB_FUNC( SEPATOOLS_GETDTAPROTOKOLL )
{
        int iSize = hb_parni( 3 );
        XMLReadStruct24 aStruct;
        int k, l;
   
        // ...    
        for ( k = 0; k < 30; k++ ) {
            l = k+1;
            aStruct.Hinweis[k] = hb_parni( 1, 23, l );
         }       
       
        SepaTools_GetDTAProtokoll( &aStruct, hb_parni( 2 ), &iSize );
        hb_storni( iSize, 3 );
       
        hb_reta( 23 );
        // ..
        hb_storni( aStruct.Hinweis, -1, 23 );
}
With best regards,
Jeanette

http://www.ctosoftware.de/
Jeanette Panitz
 
Posts: 10
Joined: Mon Oct 21, 2013 10:58 am
Location: Germany

Re: Embedding a 3rd party .dll

Postby Antonio Linares » Thu Oct 24, 2013 11:12 am

Jeanette,

You are supplying an array to the function, are the elements for the int array a subarray ?

I mean:

{ first element, second element, ... { array for ints }, more elements... }
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42094
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Embedding a 3rd party .dll

Postby Jeanette Panitz » Thu Oct 24, 2013 11:32 am

Antonio,

it's easier to explain it on another function, which also contains a struct with an array of integer-element ( int CSVFeld[30]; )
Code: Select all  Expand view

#include "Fivewin.ch"
function main()
    local aConvertCSV2XML
   
    msgInfo(SEPATOOLS_INIT( "", "", "c:\temp", "", 0 ))
   
    aConvertCSV2XML := SEPATOOLS_CONVERTCSVTOXML({ "C:\Users\panitz\Documents\Mappe1.csv", "C:\Temp\XML\XML1.xml", "27092014",;
             "", 0, 0, "TomSchmidt", "", "", "", "", "", "", "", "", 123,;
             {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0},;
             ";", "", "", "", ""})
    msgInfo( aConvertCSV2XML )
   
return nil


#pragma begindump
#include <hbapi.h>
#include <windows.h>

    // INIT-Function
    int pascal SepaTools_Init(const char *DataPath, const char *TempPath, const char *UserPath, const char *Lizenz, int Netz);

    HB_FUNC (SEPATOOLS_INIT)
    {
        hb_retni( SepaTools_Init( hb_parc( 1 ), hb_parc( 2 ), hb_parc( 3 ), hb_parc( 4 ), hb_parni( 5 ) ) );
    }
   
    // CONVERTCSVTOXML - Function

    typedef struct
    {  
        char  InputFile[255+1];    
        char  OutputFile[255+1];    
        char  AusfDatum[8+1];      
        char  Kennung[10+1];       
        int   Lastschrift;        
        int   B2B;                    
        char  Einreicher[70+1];    
        char  AuftragName[70+1];   
        char  AuftragBLZ[8+1];     
        char  AuftragKonto[11+1];   
        char  AuftragBIC[11+1];    
        char  AuftragIBAN[35+1];   
        char  CI[35+1];            
        char  Mandat[35+1];        
        char  MandatDat[8+1];      
        int   MandatStart;        
        int   CSVFeld[30];        
        char  Trennzeichen[1+1];   
        char  Grenze[1+1];           
        char  Tausend[1+1];        
        char  Komma[1+1];          
        char  Reserve[200];        
    } CSVConvertStruct30;
       
    int pascal SepaTools_ConvertCSVtoXML( const CSVConvertStruct30 *CSVConvert );
   
    HB_FUNC( SEPATOOLS_CONVERTCSVTOXML )
    {      
        int k, l;
        CSVConvertStruct30 aStruct;
               
        strcpy( aStruct.InputFile, ( char * ) hb_parc( 1, 1 ) );
        strcpy( aStruct.OutputFile, ( char * ) hb_parc( 1, 2 ) );
        strcpy( aStruct.AusfDatum, ( char * ) hb_parc( 1, 3 ) );
        strcpy( aStruct.Kennung, ( char * ) hb_parc( 1, 4 ) );
        aStruct.Lastschrift = hb_parni( 1, 5 );
        aStruct.B2B = hb_parni( 1, 6 );
        strcpy( aStruct.Einreicher, ( char * ) hb_parc( 1, 7 ) );
        strcpy( aStruct.AuftragName, ( char * ) hb_parc( 1, 8 ) );
        strcpy( aStruct.AuftragBLZ, ( char * ) hb_parc( 1, 9 ) );
        strcpy( aStruct.AuftragKonto, ( char * ) hb_parc( 1, 10 ) );
        strcpy( aStruct.AuftragBIC, ( char * ) hb_parc( 1, 11 ) );
        strcpy( aStruct.AuftragIBAN, ( char * ) hb_parc( 1, 12 ) );
        strcpy( aStruct.CI, ( char * ) hb_parc( 1, 13 ) );
        strcpy( aStruct.Mandat, ( char * ) hb_parc( 1, 14 ) );
        strcpy( aStruct.MandatDat, ( char * ) hb_parc( 1, 15 ) );
        aStruct.MandatStart = hb_parni( 1, 16 );

        for ( k = 0; k < 30; k++ ) {
            l = k+1;
            aStruct.CSVFeld[k] = hb_parni( 1, 17, l );
        }

        strcpy( aStruct.Trennzeichen, ( char * ) hb_parc( 1, 18 ) );
        strcpy( aStruct.Grenze, ( char * ) hb_parc( 1, 19 ) );
        strcpy( aStruct.Tausend, ( char * ) hb_parc( 1, 20 ) );
        strcpy( aStruct.Komma, ( char * ) hb_parc( 1, 21 ) );
        strcpy( aStruct.Reserve, ( char * ) hb_parc( 1, 22 ) );
       
        hb_retni( SepaTools_ConvertCSVtoXML( &aStruct ) );
    }

#pragma enddump 
 
With best regards,
Jeanette

http://www.ctosoftware.de/
Jeanette Panitz
 
Posts: 10
Joined: Mon Oct 21, 2013 10:58 am
Location: Germany

Re: Embedding a 3rd party .dll

Postby Antonio Linares » Thu Oct 24, 2013 12:31 pm

Jeanette,

Are you using xHarbour ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42094
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Embedding a 3rd party .dll

Postby Jeanette Panitz » Thu Oct 24, 2013 12:32 pm

Antonio,

yes, like Gilbert I'm using xHarbour.
With best regards,
Jeanette

http://www.ctosoftware.de/
Jeanette Panitz
 
Posts: 10
Joined: Mon Oct 21, 2013 10:58 am
Location: Germany

Re: Embedding a 3rd party .dll

Postby Antonio Linares » Thu Oct 24, 2013 12:38 pm

Jeanette,

Please try it this way:

Code: Select all  Expand view
PHB_ITEM pArray = hb_param( 17, HB_IT_ARRAY );

   for( k = 0; k < 30; k++ )
   {
      aStruct.CSVFeld[ k ] = hb_arrayGetNI( pArray, k + 1 );
   }
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42094
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

PreviousNext

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 95 guests