HRB curiosities...

HRB curiosities...

Postby Antonio Linares » Tue Jul 23, 2019 7:25 am

This works:
Code: Select all  Expand view
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  Expand view
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: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: HRB curiosities...

Postby Antonio Linares » Tue Jul 23, 2019 7:32 am

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

Code: Select all  Expand view
/* 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: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: HRB curiosities...

Postby Antonio Linares » Tue Jul 23, 2019 8:54 pm

Code: Select all  Expand view
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: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: HRB curiosities...

Postby Antonio Linares » Tue Jul 23, 2019 9:18 pm

Code: Select all  Expand view
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: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: HRB curiosities...

Postby Antonio Linares » Wed Jul 24, 2019 5:56 am

This is specifically for mod_harbour:

Code: Select all  Expand view
// {% 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: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: HRB curiosities...

Postby Antonio Linares » Wed Jul 24, 2019 7:20 am

mod_harbour final version:

Code: Select all  Expand view
// {% LoadHRB( "testhrb.hrb" ) %}

function Another()

   Test()

return nil
regards, saludos

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


Return to Off Topic / Otros temas

Who is online

Users browsing this forum: No registered users and 3 guests