Hello Shum, On Mar 27, 2010, at 11:05 PM, Shum wrote:
> > Hi Teo, > >> HB_FUNC( POINTER2STRING ) >> { >> PHB_ITEM p = hb_param( 1, HB_IT_POINTER ); >> PHB_ITEM n = hb_param( 2, HB_IT_NUMERIC ); >> >> if( p && n ) >> { >> PHB_ITEM s = hb_itemNew( NULL ); >> hb_itemPutCL( s, hb_itemGetPtr( p ), hb_itemGetNI( n ) ); >> hb_itemReturnRelease( s ); >> } >> } > > It seems that POINTER2STRING had to pass 2 parameters. > Because i donot know the length of the return string.... > Can I pass NIL to the 2nd parameter? and just obtain the string ? <prg> HB_FUNC( POINTER2STRING ) { PHB_ITEM p = hb_param( 1, HB_IT_POINTER ); if( p ) { PHB_ITEM s = hb_itemNew( NULL ); hb_itemPutCL( s, hb_itemGetPtr( p ), hb_pcount() > 1 ? hb_itemGetNI( hb_param( 2, HB_IT_NUMERIC ) ) : strlen( hb_itemGetPtr( p ) ) ); hb_itemReturnRelease( s ); } } </prg> best regards, Teo
_______________________________________________ Harbour mailing list (attachment size limit: 40KB) Harbour@harbour-project.org http://lists.harbour-project.org/mailman/listinfo/harbour