FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index Off Topic / Otros temas HRB curiosities...
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
HRB curiosities...
Posted: Tue Jul 23, 2019 07:25 AM
This works:
Code (fw): Select all Collapse
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 (fw): Select all Collapse
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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: HRB curiosities...
Posted: Tue Jul 23, 2019 07:32 AM
HRBs implement a garbage collector that unloads them, thats the reason for it:

Code (fw): Select all Collapse
/* 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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: HRB curiosities...
Posted: Tue Jul 23, 2019 08:54 PM
Code (fw): Select all Collapse
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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: HRB curiosities...
Posted: Tue Jul 23, 2019 09:18 PM
Code (fw): Select all Collapse
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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: HRB curiosities...
Posted: Wed Jul 24, 2019 05:56 AM
This is specifically for mod_harbour:

Code (fw): Select all Collapse
// {% 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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: HRB curiosities...
Posted: Wed Jul 24, 2019 07:20 AM
mod_harbour final version:

Code (fw): Select all Collapse
// {% LoadHRB( "testhrb.hrb" ) %}

function Another()

   Test()

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion