FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Scripting ...
Posts: 437
Joined: Fri Oct 07, 2005 12:56 PM
Scripting ...
Posted: Wed Oct 31, 2007 06:08 PM

This question is adressed to Antonio. I know that xHB have "xHbScript" . It's requirement to have something to FWH , that script will support good FWH things ... :-) . What you can say , Antonio ? ... Or maybe it's any other technique which can support FWH libs ? I'm asking for that , because it's ideas to do own ERP more flexible and , I'm thinking , scripting with FWH can do this job ... :-)

With best regards ! Rimantas

Rimantas U.
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Scripting ...
Posted: Thu Nov 01, 2007 06:30 AM

Rimantas,

You may use xHB's "xHbScript", it works fine with FWH

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 437
Joined: Fri Oct 07, 2005 12:56 PM
Scripting ...
Posted: Thu Nov 01, 2007 09:16 AM
Antonio Linares wrote:Rimantas,

You may use xHB's "xHbScript", it works fine with FWH


I know xhbScript . But I have in mind scripts which can work with FWH syntax . As a sample - open dialog with some controls - gets , buttons :

#include "FiveWin.ch"
function Main()

   local oDlg, lExit := .f., oBtn

   DEFINE DIALOG oDlg FROM 5, 5 TO 15, 40 TITLE "A Dialog Box"

   @ 3,  4 BUTTON "&Ok" OF oDlg SIZE 40, 12

   @ 3, 12 BUTTON oBtn PROMPT "&Cancel" OF oDlg SIZE 40, 12 ;
      ACTION ( MsgInfo( "Cancel" ), lExit := .t., oDlg:End() )

   ACTIVATE DIALOG oDlg VALID lExit

return nil


Will this code work with xHbScript ?

Regards !
Rimantas U.
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Scripting ...
Posted: Thu Nov 01, 2007 09:41 AM

Rimantas,

I have not tested it myself, but it should work ok :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Scripting ...
Posted: Thu Nov 01, 2007 02:13 PM

Rimantas,

I'm just curious, where are you going with this? What is the advantage to using script insead of code?

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 437
Joined: Fri Oct 07, 2005 12:56 PM
Scripting ...
Posted: Thu Nov 01, 2007 05:05 PM
James Bott wrote:
I'm just curious, where are you going with this? What is the advantage to using script insead of code?


Hello James ,

At first I want to to specify , that I'm talking about separate prgs as scripts ... It can be prg as script can run , or xbs , ppo files as they are supported from xharbour.com ...

Exist many places where the scripts are better than code . One of the best place to fit scripts are reports ... Today I'm addidng code inside exe for any report . I'm thinking that this can be changed in other way - put prg's or ppo's files in special directory , from main program in report menu ( generated from DBF ,which contain list of reports ) call needful report = script ... With database it's all working OK . But at the beggining of report I'm calling dialog/window in which user direct needfulls parameters for report . Of course , all the code is with FWH ...

I begin from reports , because this place must be very flexible - at the begining of new project users don't know possibilities of programmer and programmer can't to see future - what users will ask ... :-) . So , in mine mind , directory with prg's or precompiled ppo's , maybe xbs's , files it's the easiest way to manage such things . Now , I'm adding code , rebuilding exe , and then placing the new exe remotely in users servers . I'm thinkig that remotely to do new prg file or modify old its more easy ...

Antonio , sorry , but xbScript don't support FWH syntax . I renamed dlg.prg to dlg.xbs and tried to open that . It return error dialog with "compilation error" message ... :-) Maybe it's working and I don't know how to to run that .

So I'm asking you , that maybe something similar exist in FWH or xHarbour ...

Regards , Rimantas
Rimantas U.
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Scripting ...
Posted: Thu Nov 01, 2007 09:26 PM

Rimantas,

I just forgot this: Harbour natively supports dynamic scripting! :-) There is no need for you to use a third party scripting tool!

You create a HRB file on runtime and execute it from the application, so there is no limitations at all and you can execute any Harbour code :-)

Let me find some samples for you.

James, runtime scripting is an incredible powerfull feature, that allows to have full data driven support in your applications :-) Its the foundation of ERP applications

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Scripting ...
Posted: Fri Nov 02, 2007 12:09 AM

Rimantas,

Do you use Harbour or xHarbour ?

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Scripting ...
Posted: Fri Nov 02, 2007 02:57 AM

I have been watching this topic with interest. I am using xharbour (bcc) now. But like to know the possibilities of creating hrb files on the fly and running them both in harbour and xharbour. In principle what I am looking for is something similar. Have some code as data somewhere and run it at runtime, instead of replacing the exe for every small modification.

Regards



G. N. Rao.

Hyderabad, India
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Scripting ...
Posted: Fri Nov 02, 2007 08:40 AM
This is a simple test. Please have a copy of harbour.exe where you run this:

test.prg
#include "FiveWin.ch"

function Main()

   Compile( "another.prg" )

   __HrbRun( "another.hrb" )
   
   MsgInfo( "done" )

return nil

function Compile( cPrgName )

   WinExec( "harbour.exe " + cPrgName + " /n /gh", 0 )
   
   while ! File( cFileNoExt( cPrgName ) + ".hrb" )
      SysRefresh()
   end   
   
return nil

Another.prg
function DontNameThisMain()

   MsgInfo( "Hello world!" )

return nil

Please notice that Harbour users don't need to keep an external harbour.exe as they can use hb_CompileBuf() that compiles from the application itself
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Scripting ...
Posted: Fri Nov 02, 2007 08:44 AM

Thanks

Assuming that we precompiled a program is .hrb and stored it as data. We read the .hrb into a memory variable. How can we execute it direclty? ( without having .hrb file on disk ) ?

Regards



G. N. Rao.

Hyderabad, India
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Scripting ...
Posted: Fri Nov 02, 2007 08:46 AM

NageswaraRao,

Just copy the data to a temporal external file:

MemoWrit( "test.hrb", cHrbData )

later on, erase it:

FErase( "test.hrb" )

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Scripting ...
Posted: Fri Nov 02, 2007 08:50 AM

My mistake, you can directly execute it from memory too :-)

__HrbRun( MemoRead( "another.hrb" ) )

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Scripting ...
Posted: Fri Nov 02, 2007 09:03 AM

Yes. This is better .. Thanks

Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Scripting ...
Posted: Fri Nov 02, 2007 09:17 AM

I have tested with xharbour. In xharbour __hrbrun requires the filename as parameter. it looks like __hrbrun calls __hrbload with the file name. now if _hrbrun uses __hrbload to load the hrb file into memory, then what is the function that executes the code in the memory ? i guess we need to use that function to execute code in memory

Regards



G. N. Rao.

Hyderabad, India