Scripting ...

Scripting ...

Postby Rimantas » Wed Oct 31, 2007 6: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.
User avatar
Rimantas
 
Posts: 437
Joined: Fri Oct 07, 2005 12:56 pm
Location: Utena , Lithuania

Postby Antonio Linares » Thu Nov 01, 2007 6:30 am

Rimantas,

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

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

Postby Rimantas » Thu Nov 01, 2007 9: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 :

Code: Select all  Expand view
#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.
User avatar
Rimantas
 
Posts: 437
Joined: Fri Oct 07, 2005 12:56 pm
Location: Utena , Lithuania

Postby Antonio Linares » Thu Nov 01, 2007 9:41 am

Rimantas,

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

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

Postby James Bott » Thu Nov 01, 2007 2:13 pm

Rimantas,

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

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Rimantas » Thu Nov 01, 2007 5: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.
User avatar
Rimantas
 
Posts: 437
Joined: Fri Oct 07, 2005 12:56 pm
Location: Utena , Lithuania

Postby Antonio Linares » Thu Nov 01, 2007 9: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42073
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Fri Nov 02, 2007 12:09 am

Rimantas,

Do you use Harbour or xHarbour ?
regards, saludos

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

Postby nageswaragunupudi » Fri Nov 02, 2007 2: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
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby Antonio Linares » Fri Nov 02, 2007 8:40 am

This is a simple test. Please have a copy of harbour.exe where you run this:

test.prg
Code: Select all  Expand view
#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
Code: Select all  Expand view
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
User avatar
Antonio Linares
Site Admin
 
Posts: 42073
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby nageswaragunupudi » Fri Nov 02, 2007 8: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
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby Antonio Linares » Fri Nov 02, 2007 8:46 am

NageswaraRao,

Just copy the data to a temporal external file:

MemoWrit( "test.hrb", cHrbData )

later on, erase it:

FErase( "test.hrb" )
Last edited by Antonio Linares on Fri Nov 02, 2007 8:53 am, edited 1 time in total.
regards, saludos

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

Postby Antonio Linares » Fri Nov 02, 2007 8:50 am

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

__HrbRun( MemoRead( "another.hrb" ) )
regards, saludos

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

Postby nageswaragunupudi » Fri Nov 02, 2007 9:03 am

Yes. This is better .. Thanks
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby nageswaragunupudi » Fri Nov 02, 2007 9: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
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Next

Return to FiveWin for Harbour/xHarbour

Who is online

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