FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Harbour hb_compilebuf* function ...
Posts: 437
Joined: Fri Oct 07, 2005 12:56 PM
Harbour hb_compilebuf* function ...
Posted: Thu Oct 01, 2009 06:04 PM
Hi ,

Can't understand from C code what parameters are needfuls for this function . And what is the best way to run prgs as scripts ?

How about that : __HrbRun( hb_compileBuf( memoread( cDef_kl + cPrg + ".prg" ) ) ) ?

Another question - how to see what errors of source are in scripting prg ? I tried something like that :

Code (fw): Select all Collapse
   TRY

      __HrbRun( hb_compileBuf( memoread( cDef_kl + cPrg + ".prg" ) ) )

   CATCH e

      MsgInfo( "error ...)
      return( NIL )

   END

How to do own error analyzer ?

3-t question - can I get an return of scripting prg object ? In most situations it's needfuls to know windows handle number . So I'm doing in prg's script - define window ... activate window... and then return( oWnd:hWnd ) . But I don't know how get if from __HrbRun( ) . It's possible ?

Many thanks in advance ! With best regards !
Rimantas U.
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Harbour hb_compilebuf* function ...
Posted: Fri Oct 02, 2009 07:45 AM
Rimantas,

This way you redirect the compiler output to a file. Later you have to analyze the output file yourself for errors:
Code (fw): Select all Collapse
#include "FiveWin.ch"

function Main()
 
   FReOpen_Stderr( "comp.log", "w" )
   HB_compilebuf( HB_ARGV( 0 ), "test.prg" )
   MsgInfo( MemoRead( "comp.log" ) )

return nil

#pragma BEGINDUMP

#include <stdio.h>
#include <hbapi.h>

HB_FUNC( FREOPEN_STDERR )
{
   hb_retnl( ( LONG ) freopen( hb_parc( 1 ), hb_parc( 2 ), stderr ) );
}    

#pragma ENDDUMP
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 437
Joined: Fri Oct 07, 2005 12:56 PM
Re: Harbour hb_compilebuf* function ...
Posted: Sun Oct 04, 2009 02:53 PM
Antonio Linares wrote:
function Main()
 
   FReOpen_Stderr( "comp.log", "w" )
   HB_compilebuf( HB_ARGV( 0 ), "test.prg" )
   MsgInfo( MemoRead( "comp.log" ) )

return nil



Many thanks fro your sample ! It's working fine . But ... Antonio , with all prgs I'm getting that are errors - No code gereated ... :-) . Maybe it's needful to pass more parameters ? Libs , includes paths ?

Regards !
Rimantas U.
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Harbour hb_compilebuf* function ...
Posted: Sun Oct 04, 2009 05:48 PM
Rimantas,

You have to specify the compiler parameters this way:
Code (fw): Select all Collapse
 HB_compilebuf( HB_ARGV( 0 ), "test.prg", "-n", "-Ic:\fwh\include" )
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 437
Joined: Fri Oct 07, 2005 12:56 PM
Re: Harbour hb_compilebuf* function ...
Posted: Mon Oct 05, 2009 05:37 PM
Antonio Linares wrote:Rimantas,

You have to specify the compiler parameters this way:
Code (fw): Select all Collapse
 HB_compilebuf( HB_ARGV( 0 ), "test.prg", "-n", "-Ic:\fwh\include" )


Many thanks , Antonio ! It's working fine ! :-)

With best regards ! Rimantas
Rimantas U.
Posts: 437
Joined: Fri Oct 07, 2005 12:56 PM
Re: Harbour hb_compilebuf* function ...
Posted: Mon Oct 05, 2009 06:58 PM
Rimantas wrote:
Antonio Linares wrote:Rimantas,

You have to specify the compiler parameters this way:
Code (fw): Select all Collapse
 HB_compilebuf( HB_ARGV( 0 ), "test.prg", "-n", "-Ic:\fwh\include" )


Many thanks , Antonio ! It's working fine ! :-)



Antonio , I did something like that :

Code (fw): Select all Collapse
METHOD RunScrpt( cPrg, cParams, nWd ) CLASS TApplic
local lRet := .t.
local oRun
local cTxtFile, cLine, nFrom := 1
local cPrgs := "Prgs\"
if File( cPrgs + cPrg + ".prg" )
   TRY
      if File( "comp.log" )
         ferase( "comp.log" )
      endif
      FReOpen_Stderr( "comp.log", "w" )
      oRun := HB_compilebuf( HB_ARGV( 0 ), cPrgs + cPrg + ".prg", "-n", "-Ihrb_incl;fwh_incl" )
      cTxtFile = MemoRead( "comp.log" )
      while nFrom < Len( cTxtFile )
         cLine = ExtractLine( cTxtFile, @nFrom )
         SysRefresh()
         if Upper( StrToken( cLine, 2 ) ) == "ERROR"
            lRet := .f.
            exit
         endif
      enddo
      if !lRet
         MsgInfo( MemoRead( "comp.log" ) )
        else
         <strong>hb_HrbRun( oRun )</strong>
      endif
   CATCH e
     lRet := .f.
   END
  else
   MsgInf(  "Can't to find file - " + cPrg + ".prg ...", 2 )
   lRet := .f.
endif
return( lRet )


It's working very fine . It's wanting very little ... :-) . How to pass needful parameter to my script ? At first I did Hb_HrbRun( oRun, cParams ) . But parameter didn't apears in script . And maybe it's possibility to get return parameter from script ? If exist such possibilities ( to pass parameter and get return parameter ) - then my ERP will be the best ... :-)

With best regards !
Rimantas U.
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Harbour hb_compilebuf* function ...
Posted: Mon Oct 05, 2009 10:50 PM
Rimantas,

Try to create a public variable from your script and save inside it the result. The public variable should remain alive after the script runs:
Code (fw): Select all Collapse
public MyReturn

MyReturn := 123 // MyCode()
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 437
Joined: Fri Oct 07, 2005 12:56 PM
Re: Harbour hb_compilebuf* function ...
Posted: Tue Oct 06, 2009 05:11 AM
Antonio Linares wrote:Rimantas,

Try to create a public variable from your script and save inside it the result. The public variable should remain alive after the script runs:
Code (fw): Select all Collapse
public MyReturn

MyReturn := 123 // MyCode()


Thanks , ANtonio ! After some thinking I realized a good way to do what I wanna , something like you suggested .. :-)

Regards !
Rimantas U.

Continue the discussion