FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Returning an array from C code
Posts: 464
Joined: Tue May 16, 2006 07:47 AM
Returning an array from C code
Posted: Thu Jul 09, 2009 11:26 AM

Hi all

I need to return an array (or perhaps write to an (x)Harbour array) from a C function where I have something like

char **things

I need to iterate through things like this (given that there are int num_things of things:

for ( loop_counter = 0; loop_counter < num_things; loop_counter++ )
{
// do something here to put things[loop_counter] into the array
}
for ( loop_counter = 0; loop_counter < num_things; loop_counter++ )
{
free( things[loop_counter] );
}
free( things );

// if above is building an array I would need to pass it back here
// but if above wrote to an existing (x)harbour array then there would be no work to be done here.

Can someone help please?

Thanks

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Returning an array from C code
Posted: Thu Jul 09, 2009 04:15 PM

Doug,

Harbour function Directory() is a great example to create and fill mutidimensional arrays from C:

http://harbour-project.svn.sourceforge. ... hrev=11679

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 464
Joined: Tue May 16, 2006 07:47 AM
Re: Returning an array from C code
Posted: Thu Jul 09, 2009 08:24 PM

Thanks Antonio

Code is most instructive. Should be put to good use shortly. First target will be native CUPS support. If done as a class it would presumably be TCUPS (teacups)?

Regards

Doug

Continue the discussion