Harbour hb_compilebuf* function ...

Harbour hb_compilebuf* function ...

Postby Rimantas » Thu Oct 01, 2009 6: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: Select all  Expand view  RUN


   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.
User avatar
Rimantas
 
Posts: 437
Joined: Fri Oct 07, 2005 12:56 pm
Location: Utena , Lithuania

Re: Harbour hb_compilebuf* function ...

Postby Antonio Linares » Fri Oct 02, 2009 7: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: Select all  Expand view  RUN
#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
User avatar
Antonio Linares
Site Admin
 
Posts: 42117
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Harbour hb_compilebuf* function ...

Postby Rimantas » Sun Oct 04, 2009 2: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.
User avatar
Rimantas
 
Posts: 437
Joined: Fri Oct 07, 2005 12:56 pm
Location: Utena , Lithuania

Re: Harbour hb_compilebuf* function ...

Postby Antonio Linares » Sun Oct 04, 2009 5:48 pm

Rimantas,

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

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

Re: Harbour hb_compilebuf* function ...

Postby Rimantas » Mon Oct 05, 2009 5:37 pm

Antonio Linares wrote:Rimantas,

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


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

With best regards ! Rimantas
Rimantas U.
User avatar
Rimantas
 
Posts: 437
Joined: Fri Oct 07, 2005 12:56 pm
Location: Utena , Lithuania

Re: Harbour hb_compilebuf* function ...

Postby Rimantas » Mon Oct 05, 2009 6:58 pm

Rimantas wrote:
Antonio Linares wrote:Rimantas,

You have to specify the compiler parameters this way:
Code: Select all  Expand view  RUN
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: Select all  Expand view  RUN

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
         hb_HrbRun( oRun )
      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.
User avatar
Rimantas
 
Posts: 437
Joined: Fri Oct 07, 2005 12:56 pm
Location: Utena , Lithuania

Re: Harbour hb_compilebuf* function ...

Postby Antonio Linares » 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: Select all  Expand view  RUN

public MyReturn

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

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

Re: Harbour hb_compilebuf* function ...

Postby Rimantas » Tue Oct 06, 2009 5: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: Select all  Expand view  RUN

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.
User avatar
Rimantas
 
Posts: 437
Joined: Fri Oct 07, 2005 12:56 pm
Location: Utena , Lithuania


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 96 guests

cron