FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Array (C level) to reference variable (PRG level)
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Array (C level) to reference variable (PRG level)
Posted: Wed Jul 15, 2009 08:19 AM
This is an example how to create an array from low level (C code) and assign it to a local variable by reference (PRG code):
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