Embedding a 3rd party .dll

Jeanette Panitz
Posts: 10
Joined: Mon Oct 21, 2013 10:58 am
Location: Germany

Re: Embedding a 3rd party .dll

Post by Jeanette Panitz »

Antonio,

unfortunately this solution does not work, the program crashes.

I tried this way also a week ago and the program works only like this, but does not fill the array of integer

Code: Select all

PHB_ITEM pArray = hb_param( 1, HB_IT_ARRAY );
for ( k = 0; k < 30; k++ ) {
        aStruct.CSVFeld[k] = hb_arrayGetNI( pArray, k+1 );
}
The moment I am using another number than " 1 " the program does not work.

Is it possible to make something like that?

Code: Select all

PHB_ITEM pArray = hb_param( 1, 17, HB_IT_ARRAY );
With best regards,
Jeanette

http://www.ctosoftware.de/
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Embedding a 3rd party .dll

Post by Antonio Linares »

Jeanette,

Please try this:

Code: Select all

PHB_ITEM pArray = hb_param( 17, HB_IT_ARRAY );

if( ! pArray )
   MessageBox( 0, "not an array there", "ok", 0 );

...
 
regards, saludos

Antonio Linares
www.fivetechsoft.com
Jeanette Panitz
Posts: 10
Joined: Mon Oct 21, 2013 10:58 am
Location: Germany

Re: Embedding a 3rd party .dll

Post by Jeanette Panitz »

Antonio,
I tried your solution: the program shows the message "not an array there". After that it crashes.

Code: Select all

...
PHB_ITEM pArray = hb_param( 17, HB_IT_ARRAY );
...
if( ! pArray ) {
     MessageBox( 0, "not an array there", "ok", 0 );
}       
for ( k = 0; k < 30; k++ ) 
{
     aStruct.CSVFeld[k] = hb_arrayGetNI( pArray, k+1 );
}
...
 
With best regards,
Jeanette

http://www.ctosoftware.de/
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Embedding a 3rd party .dll

Post by Antonio Linares »

Jeanette,

This should be the right way:

Code: Select all

PHB_ITEM pArray;

hb_arrayGet( hb_param( 1, HB_IT_ARRAY ), 17, pArray );

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

Antonio Linares
www.fivetechsoft.com
Jeanette Panitz
Posts: 10
Joined: Mon Oct 21, 2013 10:58 am
Location: Germany

Re: Embedding a 3rd party .dll

Post by Jeanette Panitz »

Thank you very much Antonio,

this solution works fine.

Do you also know how to return an array of integer?
I have another function (with 2 structs), that returns information of a xml-file.
If there are discrepancies in the xml-file the array of int "Hinweis[30]" should return error-codes.

Code: Select all

// 34 SepaTools_XMLLesen with 2 structs
    typedef struct 
    { 
        int   Lastschrift;          
        int   SummeAnzahl;           
        char  SummeBetrag[12+1];    
        char  MsgId[35+1];          
        char  ErstDatum[8+1];       
        char  ErstZeit[8+1];        
        char  EinreicherName[70+1]; 
    } XMLGroupStruct34; 
    
    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  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];           
    } XMLReadStruct34; 

    int pascal SepaTools_XMLLesen( const int *First, XMLGroupStruct34 *GroupStruct, XMLReadStruct34 *ReadStruct );
    
    HB_FUNC( SEPATOOLS_XMLLESEN )
    {
        int k;
        int iSize = hb_parni( 1 );
        XMLGroupStruct34 aStruct1;
        XMLReadStruct34  aStruct2;  
        int nReturn;
        PHB_ITEM pArray;

        nReturn = SepaTools_XMLLesen( &iSize, &aStruct1, &aStruct2 );
        hb_storni( iSize, 1 );
        hb_arraySet( hb_param( 2, HB_IT_ARRAY ), 23, pArray );
                
        hb_reta( 31 );
        hb_storni( aStruct1.Lastschrift, -1, 1 );
        hb_storni( aStruct1.SummeAnzahl, -1, 2 );
        hb_storc( aStruct1.SummeBetrag, -1, 3 );
        hb_storc( aStruct1.MsgId, -1, 4 );
        hb_storc( aStruct1.ErstDatum, -1, 5 );
        hb_storc( aStruct1.ErstZeit, -1, 6 );
        hb_storc( aStruct1.EinreicherName, -1, 7 );
        hb_storc( aStruct2.PmInfoId, -1, 8 );
        hb_storc( aStruct2.AusfDatum, -1, 9 );
        hb_storc( aStruct2.AuftragName, -1, 10 );
        hb_storc( aStruct2.AuftragBIC, -1, 11 );
        hb_storc( aStruct2.AuftragIBAN, -1, 12 );
        hb_storc( aStruct2.AuftragAbwName, -1, 13 );
        hb_storc( aStruct2.AuftragCI, -1, 14 );
        hb_storc( aStruct2.EmpfName, -1, 15 );
        hb_storc( aStruct2.EmpfBIC, -1, 16 );
        hb_storc( aStruct2.EmpfIBAN, -1, 17 );
        hb_storc( aStruct2.EmpfAbwName, -1, 18 );
        hb_storc( aStruct2.Purpose, -1, 19 );
        hb_storc( aStruct2.Betrag, -1, 20 );
        hb_storc( aStruct2.EndToEndId, -1, 21 );
        hb_storc( aStruct2.MandatId, -1, 22 );
        hb_storc( aStruct2.MandatDatum, -1, 23 );
        hb_storc( aStruct2.SequenceType, -1, 24 );
        hb_storni( aStruct2.B2B, -1, 25 );
        hb_storni( aStruct2.SammlerAnzahl, -1, 26 );
        hb_storc( aStruct2.SammlerSumme, -1, 27 );
        hb_storc( aStruct2.Zweck1, -1, 28 );
        hb_storc( aStruct2.Zweck2, -1, 29 );
        for ( k = 0; k < 30; k++ ) 
        {
            hb_storni( aStruct2.Hinweis[k],  -1, 30, k+1 );
        }
        hb_storni( nReturn, -1, 31 );
    }
 
The program runs, but I get always error-code "0" (in the array of int "Hinweis") even when I change the xml-file.
With best regards,
Jeanette

http://www.ctosoftware.de/
Post Reply