FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Array (desde C) a variable por referencia (desde PRG)
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Array (desde C) a variable por referencia (desde PRG)
Posted: Wed Jul 15, 2009 08:21 AM
Aqui teneis un ejemplo de como crear un array desde código C y asignarlo a una variable pasada por referencia desde PRG:
Code (fw): Select all Collapse
function Main()

   local a

   Test( @a )

   MsgInfo( ValType( a ) )
   MsgInfo( Len( a ) )

return nil

#pragma BEGINDUMP

#include <hbapi.h>
#include <hbapiitm.h>

HB_FUNC( TEST )
{
   PHB_ITEM pArray = hb_itemNew( NULL );

   hb_arrayNew( pArray, 4 ); // 4 elements
   
   hb_arraySetC( pArray, 1, "Hello" ); // a string
   hb_arraySetNL( pArray, 2, 123 );    // a number
   hb_arraySetL( pArray, 3, TRUE );    // a logical
   hb_arraySetDL( pArray, 4, 11223344 ); // a date
   
   hb_itemCopy( hb_param( 1, HB_IT_ANY ), pArray );
   hb_itemRelease( pArray );
}

#pragma ENDDUMP
regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion