Hi, friend!
An example:
In Harbour:
a:=10; b=0.5
r := my_add( a, b )
In #Pragma:
HB_FUNC( MY_ADD )
{
double nA = hb_param( 1, HB_IT_NUMERIC );
double nB = hb_param( 2, HB_IT_NUMERIC );
double r = nA + nB;
hb_retnd( r );
}
In Harbour:
a := {1,2,3,4,5,6}
? my_pow( a, 4 )
In #Pragma:
HB_FUNC( MY_POW )
{
PHB_ITEM pArray = hb_param( 1, HB_IT_ARRAY );
double nPower = hb_param( 2, HB_IT_NUMERIC );
int i;
double res;
HB_MAXINT nLong = hb_arrayLen( pArray );
/* arrays on Harbour begin in 1 */
PHB_ITEM newArray = hb_itemArrayNew( nLong );
for ( i=1; i<=nLong; ++i ){
PHB_ITEM pElem = hb_itemArrayGet( pArray, i );
res = pow ( hb_itemGetND( pElem ), (double) nPower );
hb_arraySetND( newArray, i, res );
hb_itemRelease( pElem );
}
hb_ret ( newArray ); // not remember hb_ret... ?? find in Harbour's source code.
hb_itemRelease( newArray );
}
Google traductor: "nunca modifiques el contenido de un array pasado como parámetro: crea uno nuevo, y devuelve ese array"
More examples in all Harbour's source code!
Saludos!