HRB curiosities...

Post Reply
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

HRB curiosities...

Post by Antonio Linares »

This works:

Code: Select all

function Main()

   local o := AddFunc( "function Orm()" + CRLF + "return nil" )
   
   ? HB_ISFUNCTION( "ORM" )

return nil

function AddFunc( cCode )

return hb_HrbLoad( 1, hb_CompileFromBuf( cCode, .T., "-n" ) )
and this doesn't:

Code: Select all

function Main()

   AddFunc( "function Orm()" + CRLF + "return nil" )
   
   ? HB_ISFUNCTION( "ORM" )

return nil

function AddFunc( cCode )

return hb_HrbLoad( 1, hb_CompileFromBuf( cCode, .T., "-n" ) )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: HRB curiosities...

Post by Antonio Linares »

HRBs implement a garbage collector that unloads them, thats the reason for it:

Code: Select all

/* HRB module destructor */
static HB_GARBAGE_FUNC( hb_hrb_Destructor )
{
  PHRB_BODY * pHrbPtr = ( PHRB_BODY * ) Cargo;
  if( *pHrbPtr )
  {
     hb_hrbUnLoad( *pHrbPtr );
     *pHrbPtr = NULL;
  }
}
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: HRB curiosities...

Post by Antonio Linares »

Code: Select all

function Main()

   local o := AddFunc( "function Orm()" + CRLF + "AP_RPuts( 'yes' )" + CRLF + "return nil" )
   
   Execute( "function test()" + CRLF + "Orm()" + CRLF + "return nil" )

return nil

function AddFunc( cCode )

return hb_HrbLoad( 0, hb_CompileFromBuf( cCode, .T., "-n" ) )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: HRB curiosities...

Post by Antonio Linares »

Code: Select all

function Another()

   local o := hb_HrbLoad( 1, MemoRead( hb_GetEnv( "PRGPATH" ) + "/testhrb.hrb" ) )
   
   Execute( "function test()" + CRLF + "Main()" + CRLF + "return nil" )

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: HRB curiosities...

Post by Antonio Linares »

This is specifically for mod_harbour:

Code: Select all

// {% AAdd( getList, hb_HrbLoad( 0, hb_CompileFromBuf( "function Orm()" + Chr( 13 ) + Chr( 10 ) + "AP_RPuts( 'yes' )" + Chr( 13 ) + Chr( 10 ) + "return nil", .T., "-n" ) ) ) %}

function Main()

  Orm()

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: HRB curiosities...

Post by Antonio Linares »

mod_harbour final version:

Code: Select all

// {% LoadHRB( "testhrb.hrb" ) %}

function Another()

   Test()

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply