Extend Codeblock

Post Reply
User avatar
cmsoft
Posts: 1300
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina
Has thanked: 1 time
Been thanked: 2 times

Extend Codeblock

Post by cmsoft »

Como puedo hacer para crear un Extend Codeblock, pero sacando el bloque de codigo desde un texto?

Code: Select all | Expand

#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
 
emotta_no
Posts: 33
Joined: Thu Jul 04, 2013 9:28 pm

Re: Extend Codeblock

Post by emotta_no »

do it

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

Code: Select all | Expand



    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 )
     
 
User avatar
Antonio Linares
Site Admin
Posts: 42651
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 62 times
Been thanked: 94 times
Contact:

Re: Extend Codeblock

Post by Antonio Linares »

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
User avatar
Antonio Linares
Site Admin
Posts: 42651
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 62 times
Been thanked: 94 times
Contact:

Re: Extend Codeblock

Post by Antonio Linares »

regards, saludos

Antonio Linares
www.fivetechsoft.com
emotta_no
Posts: 33
Joined: Thu Jul 04, 2013 9:28 pm

Re: Extend Codeblock

Post by emotta_no »

This only works Harbour? For XHARBOUR what solution?
User avatar
cmsoft
Posts: 1300
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina
Has thanked: 1 time
Been thanked: 2 times

Re: Extend Codeblock

Post by cmsoft »

Antonio, a partir de que versión de FiveWin está esa función? Yo tengo la 11.12 y no tengo esa funcion...
User avatar
Antonio Linares
Site Admin
Posts: 42651
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 62 times
Been thanked: 94 times
Contact:

Re: Extend Codeblock

Post by Antonio Linares »

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
emotta_no
Posts: 33
Joined: Thu Jul 04, 2013 9:28 pm

Re: Extend Codeblock

Post by emotta_no »

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] )
User avatar
Antonio Linares
Site Admin
Posts: 42651
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 62 times
Been thanked: 94 times
Contact:

Re: Extend Codeblock

Post by Antonio Linares »

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
emotta_no
Posts: 33
Joined: Thu Jul 04, 2013 9:28 pm

Re: Extend Codeblock

Post by emotta_no »

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