FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Extend Codeblock
Posts: 1344
Joined: Wed Nov 16, 2005 09:14 PM
Extend Codeblock
Posted: Wed Jul 30, 2014 11:22 AM
Como puedo hacer para crear un Extend Codeblock, pero sacando el bloque de codigo desde un texto?

Code (fw): Select all Collapse
#include "FiveWin.ch"
STATIC FUNCTION ExtendCodeBlock()
local bBloque, cBloque, i
聽 聽// Este c脙鲁digo funciona bien 聽 
聽 聽bBloque := { || 
聽 聽 聽 聽 聽 聽 聽 聽 LOCAL i
聽 聽 聽 聽 聽 聽 聽 聽 FOR i := 1 to 10
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽MSGINFO(STR(i,1)) 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽
聽 聽 聽 聽 聽 聽 聽 聽 NEXT i 
聽 聽 聽 聽 聽 聽 聽 聽 return nil 
聽 聽 聽 聽 聽 聽 聽 聽 } 

聽 聽Eval(bBloque) 
聽 聽// Este c脙鲁digo funciona bien
聽 聽cBloque := "{|i| MsgInfo(i)}"
聽 聽bBloque := &(cBloque)
聽 聽// Esto da error 
聽 聽Eval(bBloque,1) 
聽 聽cBloque := "{|| "+CHR(10)+; 
聽 聽 聽 聽 聽 聽 聽 " 聽LOCAL i "+CHR(10)+;
聽 聽 聽 聽 聽 聽 聽 " 聽FOR i := 1 to 10 "+CHR(10)+;
聽 聽 聽 聽 聽 聽 聽 " 聽 聽 MSGINFO(STR(i,1)) 聽"+CHR(10)+;
聽 聽 聽 聽 聽 聽 聽 " 聽NEXT i "+CHR(10)+;
聽 聽 聽 聽 聽 聽 聽 " 聽return nil}"
聽 聽bBloque := &(cBloque) 聽 
聽 聽Eval(bBloque) 
聽 聽// Este da error
聽 聽cBloque := MemoRead( "func.prg")
聽 聽bBloque := &(cBloque)
聽 聽Eval(bBloque) 聽 聽
return nil
Posts: 33
Joined: Thu Jul 04, 2013 09:28 PM
Re: Extend Codeblock
Posted: Thu Jul 31, 2014 02:15 PM
do it

viewtopic.php?f=3&t=25813&p=141241&hilit=hrbrun#p141241

Code (fw): Select all Collapse
    function Run_prg( cPrg )
    local oHrb, cResult
    if !db_conn()
       return( NIL )
    endif
    if !file( cPrg + ".prg" )
       MsgAlert( "Nera tokio failo: " + cPrg + ".prg !" )
       return( NIL )
    endif

    FReOpen_Stderr( "run_prg.log", "w" )
    HB_Compile( "", cPrg + ".prg", "/n", "/gh", "-ID:\A\fwh\include", "-ID:\A\hrbg\include" )
    oHrb = HB_HRBLOAD( cPrg + ".hrb" )
    HB_HRBDO( oHrb )
    HB_HRBUNLOAD( oHrb )
    oHrb = NIL
    return( NIL )
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Extend Codeblock
Posted: Thu Jul 31, 2014 04:11 PM

Usa la funci贸n de FWH Execute( cSourceCode [, params...] ) --> uReturnValue

Es la forma m谩s simple de ejecutar c贸digo desde texto :-)

Tienes un ejemplo de uso en FWH\samples\FiveDBU.prg

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Extend Codeblock
Posted: Thu Jul 31, 2014 04:19 PM
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 33
Joined: Thu Jul 04, 2013 09:28 PM
Re: Extend Codeblock
Posted: Thu Jul 31, 2014 05:29 PM

This only works Harbour? For XHARBOUR what solution?

Posts: 1344
Joined: Wed Nov 16, 2005 09:14 PM
Re: Extend Codeblock
Posted: Thu Jul 31, 2014 09:11 PM

Antonio, a partir de que versi贸n de FiveWin est谩 esa funci贸n? Yo tengo la 11.12 y no tengo esa funcion...

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Extend Codeblock
Posted: Fri Aug 01, 2014 06:03 AM

La funci贸n Execute() se a帽adi贸 en FWH 12.07.

Esta funci贸n usa la l铆breria hbcplr.lib de Harbour, la cual no existe en xHarbour, asi que s贸lo est谩 disponible para los usuarios de Harbour.

Emota,

The only solution for xHarbour users is to migrate to Harbour :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 33
Joined: Thu Jul 04, 2013 09:28 PM
Re: Extend Codeblock
Posted: Fri Aug 01, 2014 01:50 PM

Thanks Antonio.. your solution is best. I can't to migrate for Harbour now because I use SQLRDD. I use this code for this solution...

oScript := __hrbLoad( cArquivo )
__hrbDo( oScript,aPar[1],aPar[2],aPar[3],aPar[4],aPar[5],aPar[6],aPar[7],aPar[8],aPar[9] )

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Extend Codeblock
Posted: Fri Aug 01, 2014 02:39 PM

Emotta,

The really nice thing about function Execute() is that the whole process is done in memory, so no files are involved at all, no need to call an external compiler.

Its really nice :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 33
Joined: Thu Jul 04, 2013 09:28 PM
Re: Extend Codeblock
Posted: Fri Aug 01, 2014 06:22 PM

Thanks Antonio, I want to use Harbour... but now it's impossible.

Continue the discussion