Crear function para Script de Harbour

Crear function para Script de Harbour

Postby Compuin » Sun Aug 12, 2018 12:54 am

Hola foro

Necesito crear una funcion que me ejecute un .prg externo de mi .exe mediante script. Lo he estado haciendo asi:

Code: Select all  Expand view
EJECUTAR("EJEMPLO")
, donde ejecutar es la funcion y ejemplo es un .prg (ejemplo.prg)

Mi funcion para llamar al script la estoy haciendo asi:

Code: Select all  Expand view
FUNCTION Ejecutar( cCode )
   local oHrb, cResult, bOldError

   FReOpen_Stderr( "comp.log", "w" )
   oHrb = HB_CompileFromBuf( cCode, "-n", "-Ic:\fwh\include", "-Ic:\harbour\include" )

   if ! Empty( oHrb )
      BEGIN SEQUENCE
      bOldError = ErrorBlock( { | o | DoBreak( o ) } )
      hb_HrbRun( oHrb )
      END SEQUENCE
      ErrorBlock( bOldError )
   endif
  */
return nil

//----------------------------------------------------------------------------//
FUNCTION DoBreak( oError )

   local cInfo := oError:operation, n

   if ValType( oError:Args ) == "A"
      cInfo += "   Args:" + CRLF
      for n = 1 to Len( oError:Args )
         MsgInfo( oError:Args[ n ] )
         cInfo += "[" + Str( n, 4 ) + "] = " + ValType( oError:Args[ n ] ) + ;
                   "   " + cValToChar( oError:Args[ n ] ) + CRLF
      next
   endif

   MsgStop( oError:Description + CRLF + cInfo,;
            "Script error at line: " + AllTrim( Str( ProcLine( 2 ) ) ) )

   BREAK

return nil


Con este codigo obtengo el siguiente error

Image

Agradezco quien pueda ayudarme u orientarme

Gracias de antemano
FWH 20.12
Hbmk2 32/64 Bits (Build 19.29.30133)
Microsoft Visual C 32 Bits
MySql 8.0.24 32/64 Bits
VS Code
Compuin
 
Posts: 1214
Joined: Tue Dec 28, 2010 1:29 pm
Location: Quebec, Canada

Re: Crear function para Script de Harbour

Postby Antonio Linares » Sun Aug 12, 2018 5:56 am

EJECUTAR( MemoRead( "ejemplo.prg" ) )

y elimina esta línea:
// FReOpen_Stderr( "comp.log", "w" )

y modifica esta línea asi:
oHrb = HB_CompileFromBuf( cCode, .T., "-n", "-Ic:\fwh\include", "-Ic:\harbour\include" )
regards, saludos

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

Re: Crear function para Script de Harbour

Postby Compuin » Sun Aug 12, 2018 12:32 pm

Hola Antonio

Hice los cambios sugeridos y ahora me da este error:

Code: Select all  Expand view
Error description: Error COMPILER/20  Incomplete statement or unbalanced delimiters: line:1

Stack Calls
===========
   Called from:  => HB_COMPILEFROMBUF( 0 )
   Called from: .\prg\funciones.prg => EJECUTAR( 407 )


Aca el codigo de la funcion:

Code: Select all  Expand view
FUNCTION Ejecutar( cCode )
   local oHrb, cResult, bOldError, oResult

   oHrb = HB_CompileFromBuf( cCode, .T., "-n", "-Ic:\fwh\include", "-Ic:\harbour\include" )

   if ! Empty( oHrb )
      BEGIN SEQUENCE
      bOldError = ErrorBlock( { | o | DoBreak( o ) } )
      hb_HrbRun( oHrb )
      END SEQUENCE
      ErrorBlock( bOldError )
   endif
  */
return nil

//----------------------------------------------------------------------------//
FUNCTION DoBreak( oError )

   local cInfo := oError:operation, n

   if ValType( oError:Args ) == "A"
      cInfo += "   Args:" + CRLF
      for n = 1 to Len( oError:Args )
         MsgInfo( oError:Args[ n ] )
         cInfo += "[" + Str( n, 4 ) + "] = " + ValType( oError:Args[ n ] ) + ;
                   "   " + cValToChar( oError:Args[ n ] ) + CRLF
      next
   endif

   MsgStop( oError:Description + CRLF + cInfo,;
            "Script error at line: " + AllTrim( Str( ProcLine( 2 ) ) ) )

   BREAK

return nil
FWH 20.12
Hbmk2 32/64 Bits (Build 19.29.30133)
Microsoft Visual C 32 Bits
MySql 8.0.24 32/64 Bits
VS Code
Compuin
 
Posts: 1214
Joined: Tue Dec 28, 2010 1:29 pm
Location: Quebec, Canada

Re: Crear function para Script de Harbour

Postby Antonio Linares » Sun Aug 12, 2018 12:35 pm

Cual es el código de ejemplo.prg ?
regards, saludos

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

Re: Crear function para Script de Harbour

Postby Compuin » Sun Aug 12, 2018 12:44 pm

Code: Select all  Expand view
#Include "Fivewin.ch"

// nLen= Tamaño de la Barra
FUNCTION EJEMPLO()
  LOCAL nLen:=20
RETURN nLen
FWH 20.12
Hbmk2 32/64 Bits (Build 19.29.30133)
Microsoft Visual C 32 Bits
MySql 8.0.24 32/64 Bits
VS Code
Compuin
 
Posts: 1214
Joined: Tue Dec 28, 2010 1:29 pm
Location: Quebec, Canada

Re: Crear function para Script de Harbour

Postby Antonio Linares » Sun Aug 12, 2018 12:53 pm

Prueba a quitar el include:

// #Include "Fivewin.ch"
regards, saludos

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

Re: Crear function para Script de Harbour

Postby Compuin » Sun Aug 12, 2018 12:56 pm

Antonio Linares wrote:Prueba a quitar el include:

// #Include "Fivewin.ch"


Con esto vuelve a mostrar el error "Se detecto corrpcion HB_HRBRUN"
FWH 20.12
Hbmk2 32/64 Bits (Build 19.29.30133)
Microsoft Visual C 32 Bits
MySql 8.0.24 32/64 Bits
VS Code
Compuin
 
Posts: 1214
Joined: Tue Dec 28, 2010 1:29 pm
Location: Quebec, Canada

Re: Crear function para Script de Harbour

Postby Compuin » Mon Aug 13, 2018 4:25 pm

Alguna solucion?
FWH 20.12
Hbmk2 32/64 Bits (Build 19.29.30133)
Microsoft Visual C 32 Bits
MySql 8.0.24 32/64 Bits
VS Code
Compuin
 
Posts: 1214
Joined: Tue Dec 28, 2010 1:29 pm
Location: Quebec, Canada

Re: Crear function para Script de Harbour

Postby Antonio Linares » Mon Aug 13, 2018 6:17 pm

Que version de Harbour estas usando ?
regards, saludos

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

Re: Crear function para Script de Harbour

Postby Compuin » Mon Aug 13, 2018 7:24 pm

Antonio Linares wrote:Que version de Harbour estas usando ?


Harbour 3.2
FWH 20.12
Hbmk2 32/64 Bits (Build 19.29.30133)
Microsoft Visual C 32 Bits
MySql 8.0.24 32/64 Bits
VS Code
Compuin
 
Posts: 1214
Joined: Tue Dec 28, 2010 1:29 pm
Location: Quebec, Canada

Re: Crear function para Script de Harbour

Postby Antonio Linares » Tue Aug 14, 2018 6:14 am

En que línea reporta el error ?

Copia aqui toda la información que te aparezca
regards, saludos

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

Re: Crear function para Script de Harbour

Postby Compuin » Tue Aug 14, 2018 1:21 pm

Aca el codigo completo

demo.prg

Code: Select all  Expand view
#include "FiveWin.ch"

FUNCTION MAIN()

ejecutar (MemoRead("medida.prg"))

return nil


ejecutar.prg

Code: Select all  Expand view
#include "FiveWin.ch"

FUNCTION Ejecutar( cCode )
   local oHrb, cResult, bOldError, oResult

   oHrb = HB_CompileFromBuf( cCode, .T., "-n", "-Ic:\fwh\include", "-Ic:\harbour\include" )

   if ! Empty( oHrb )
      BEGIN SEQUENCE
      bOldError = ErrorBlock( { | o | DoBreak( o ) } )
      hb_HrbRun( oHrb )
      END SEQUENCE
      ErrorBlock( bOldError )
   endif
  */
return nil

//----------------------------------------------------------------------------//
FUNCTION DoBreak( oError )

   local cInfo := oError:operation, n

   if ValType( oError:Args ) == "A"
      cInfo += "   Args:" + CRLF
      for n = 1 to Len( oError:Args )
         MsgInfo( oError:Args[ n ] )
         cInfo += "[" + Str( n, 4 ) + "] = " + ValType( oError:Args[ n ] ) + ;
                   "   " + cValToChar( oError:Args[ n ] ) + CRLF
      next
   endif

   MsgStop( oError:Description + CRLF + cInfo,;
            "Script error at line: " + AllTrim( Str( ProcLine( 2 ) ) ) )

   BREAK

return nil


medida.prg

Code: Select all  Expand view
#Include "Fivewin.ch"

FUNCTION MEDIDA()
  ? "mensaje"
RETURN .T.


Y aqui el error

Image
FWH 20.12
Hbmk2 32/64 Bits (Build 19.29.30133)
Microsoft Visual C 32 Bits
MySql 8.0.24 32/64 Bits
VS Code
Compuin
 
Posts: 1214
Joined: Tue Dec 28, 2010 1:29 pm
Location: Quebec, Canada

Re: Crear function para Script de Harbour

Postby Antonio Linares » Wed Aug 15, 2018 6:53 am

En vez de:

hb_HrbRun( oHrb )

Hazlo así:

uRet = hb_HrbDo( hb_HrbLoad( oHrb ), ... )
regards, saludos

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

Re: Crear function para Script de Harbour

Postby xmanuel » Wed Aug 15, 2018 9:18 am

No sé si será eso pero mirad en el código:
Code: Select all  Expand view

    #include "FiveWin.ch"

    FUNCTION Ejecutar( cCode )
       local oHrb, cResult, bOldError, oResult

       oHrb = HB_CompileFromBuf( cCode, .T., "-n", "-Ic:\fwh\include", "-Ic:\harbour\include" )

       if ! Empty( oHrb )
          BEGIN SEQUENCE
          bOldError = ErrorBlock( { | o | DoBreak( o ) } )
          hb_HrbRun( oHrb )
          END SEQUENCE
          ErrorBlock( bOldError )
       endif
      */ <------------------------------------------------------------------------------------------------------------------ esto sobra aquí ----------------------------------------------------------------------------
    return nil

    //----------------------------------------------------------------------------//
    FUNCTION DoBreak( oError )

       local cInfo := oError:operation, n

       if ValType( oError:Args ) == "A"
          cInfo += "   Args:" + CRLF
          for n = 1 to Len( oError:Args )
             MsgInfo( oError:Args[ n ] )
             cInfo += "[" + Str( n, 4 ) + "] = " + ValType( oError:Args[ n ] ) + ;
                       "   " + cValToChar( oError:Args[ n ] ) + CRLF
          next
       endif

       MsgStop( oError:Description + CRLF + cInfo,;
                "Script error at line: " + AllTrim( Str( ProcLine( 2 ) ) ) )

       BREAK

    return nil


 
______________________________________________________________________________
Sevilla - Andalucía
xmanuel
 
Posts: 761
Joined: Sun Jun 15, 2008 7:47 pm
Location: Sevilla

Re: Crear function para Script de Harbour

Postby Compuin » Wed Aug 15, 2018 12:11 pm

Antonio Linares wrote:En vez de:

hb_HrbRun( oHrb )

Hazlo así:

uRet = hb_HrbDo( hb_HrbLoad( oHrb ), ... )


El mismo error de corrupcion
FWH 20.12
Hbmk2 32/64 Bits (Build 19.29.30133)
Microsoft Visual C 32 Bits
MySql 8.0.24 32/64 Bits
VS Code
Compuin
 
Posts: 1214
Joined: Tue Dec 28, 2010 1:29 pm
Location: Quebec, Canada

Next

Return to FiveWin para Harbour/xHarbour

Who is online

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