Page 1 of 1

Script Question

PostPosted: Thu Apr 19, 2018 8:37 pm
by Jeff Barnes
I am using the scripts ability with harbour and FWH via the Execute(code) function.

I get an error when I try to use the FileCopy() function in my program (see code below).
Any ideas why I get this error: "Error description: Error BASE/6101 Unknown or unregistered symbol: FILECOPY"

I get the error with other functions as well (like HB_Base64Encode() )

Code: Select all  Expand view

#include "FiveWin.ch"
#define CRLF CHR(13)+CHR(10)

Function MainTest()
   
   cText:= "#include 'Fivewin.ch'"+CRLF
   cText += "Function Main()"+CRLF
   cText += "   FileCopy( 'c:\test\FileA.txt', 'c:\test\FileB.txt' )"+CRLF
   cText += "Return Nil"
   Execute( cText )
Return Nil

function Execute( cCode, ... )
   local oHrb, cResult, bOldError, uRet
   local cFWheaders := "c:\FWH1611\include"
   local cHBheaders := "c:\harbour\include"

   oHrb = HB_CompileFromBuf( cCode, "-n", "-I" + cFWheaders, "-I" + cHBheaders )
   if ! Empty( oHrb )
      BEGIN SEQUENCE
         uRet = hb_HrbDo( hb_HrbLoad( oHrb ), ... )
      END SEQUENCE
   endif
return uRet

 

Re: Script Question

PostPosted: Thu Apr 19, 2018 9:04 pm
by vilian
Maybe this function is not included in your exe.

Try to include an EXTERNAL FileCopy in your main program.

Re: Script Question

PostPosted: Thu Apr 19, 2018 9:15 pm
by Jeff Barnes
Thank you, that fixed it :D

Re: Script Question

PostPosted: Fri Apr 20, 2018 1:51 pm
by rhlawek
Jeff,

I am curious, what is the advantage of compiling code such as this to .hrb vs just making the call to FileCopy() directly? I realize FileCopy() here is likely just an example, but I'm trying to understand the why of this.

Robb

Re: Script Question

PostPosted: Fri Apr 20, 2018 2:03 pm
by Jeff Barnes
Hi Robb,

I have an application that is sending HL7 result messages back to the hospital main system.
This app can have multiple "sites" and each site typically requires slight differences in the result message.
What I've done is create a result.prg file with the basic info for a result message for each site.
Then I can simply modify the result.prg per site to make the slight changes.
This allows me to keep my "main" code the same for everyone but still allow for changes in code without any rebuilding of the app.
If a customer requires a change to the result message later on, I can make the changes to the result.prg file without any downtime for the users.

Re: Script Question

PostPosted: Fri Apr 20, 2018 2:10 pm
by vilian
I think HRB is amazing !!
We have a very big application, with more than 400 modules and its EXE has only 7Mb, thanks to HRB files ;)

Re: Script Question

PostPosted: Fri Apr 20, 2018 2:18 pm
by rhlawek
Thank you for the reply Jeff.

Vilian, I didn't mean to imply there was an issue using HRB, I use them as well, but never quite in this context. I actually write my programs so I have a basic executable (completely functional but very dynamic), then serve all the program logic up to those executables as portable objects via a REST service.

Robb

Re: Script Question

PostPosted: Fri Apr 20, 2018 6:07 pm
by Antonio Linares
Robb,

The ability to compile and execute code at runtime is the essence of the ERP applications: applications that grow and adapt to the needs of each customer without having to build new EXEs for each one.

You can turn any app into a powerful ERP system just using this technique :-)

No need to build HRB files. Simply compile and execute at runtime using hb_CompileFromBuff(). I recently posted how to catch the compiler reported errors.

Re: Script Question

PostPosted: Fri Apr 20, 2018 6:19 pm
by rhlawek
Antonio,

Isn't there a license constraint for distributing a non-open source app containing and using hb_CompileFromBuff()?

Robb

Re: Script Question

PostPosted: Fri Apr 20, 2018 6:47 pm
by Antonio Linares
Robb,

The way I see it is that if there is someone that ask you to show your source code, you should provide it. Thats all.