Page 6 of 28
Re: HMGSCRIPT 2012: Programming For The Web in The Right Way
Posted: Sat Jun 02, 2012 6:42 am
by Rathinagiri
Great Roberto!
I have to study a lot this weekend to cope up with the improvements.
Re: HMGSCRIPT 2012: Programming For The Web in The Right Way
Posted: Sat Jun 02, 2012 11:49 am
by Rossine
Hi Roberto,
Wow
Thank you for being expanding our horizons
I work for many years with HRB. What do you need ?
Below an example of how to put generate it and run it.
Code: Select all
#include "minigui.ch"
PROCEDURE Main
DEFINE WINDOW Win_Main ;
AT 0,0 ;
WIDTH 600 ;
HEIGHT 400 ;
TITLE 'Test program' ;
MAIN
DEFINE STATUSBAR ;
FONT 'Times New Roman' SIZE 12
STATUSITEM ''
END STATUSBAR
@10,10 BUTTON Btn_1 ;
CAPTION 'Run Script' ;
WIDTH 200 ;
HEIGHT 25 ;
ONCLICK RunScript()
END WINDOW
Win_Main.StatusBar.Item(1) := 'HMG Power Ready'
CENTER WINDOW Win_Main
ACTIVATE WINDOW Win_Main
RETURN
PROCEDURE RunScript
local CONTENT, HANDLE_HRB, PRG, HRBCODE
PRG := ;
"proc p()" + hb_eol() + ;
" SetProperty ( 'Win_Main', 'StatusBar' , 'Item' , 1 , 'Hello World' ) "+ hb_eol() + ;
" MsgInfo( 'Hello World' )" + hb_eol() + ;
"return"
HRBCODE := hb_compileFromBuf( PRG, "harbour", "-n", "-w3", "-es2", "-q0" )
memowrit( "myhrb.hrb", sx_encrypt( HRBCODE, "myPaswdKey" ) )
CONTENT := sx_decrypt( memoread( "myhrb.hrb" ), "myPaswdKey" )
HANDLE_HRB := hb_hrbload( CONTENT )
hb_hrbDo( HANDLE_HRB )
hb_hrbunload( HANDLE_HRB )
RETURN
Thank you very much for all
Rossine.
Re: HMGSCRIPT 2012: Programming For The Web in The Right Way
Posted: Sat Jun 02, 2012 12:03 pm
by Rathinagiri
That is so cool Rossine.

Re: HMGSCRIPT 2012: Programming For The Web in The Right Way
Posted: Sat Jun 02, 2012 12:05 pm
by Rathinagiri
Roberto,
demo.server.html is working fine (only) in Chrome.
wssocket.exe should be run as an administrator and firewall should be opened up.
Re: HMGSCRIPT 2012: Programming For The Web in The Right Way
Posted: Sat Jun 02, 2012 12:12 pm
by Rathinagiri
Now, my basic doubts:
1. Can wssocket server be started in a Linux machine.
2. Can we make it run in a leased web space provider's system? (for example, can I someway start wssocket server in our forum's server providers system?)
I have uploaded hmgscript in
www.hmgforum.com/hmgscript. So, we can test the behavior immediately.
Re: HMGSCRIPT 2012: Programming For The Web in The Right Way
Posted: Sat Jun 02, 2012 12:12 pm
by Roberto Lopez
rathinagiri wrote:Roberto,
demo.server.html is working fine (only) in Chrome.
wssocket.exe should be run as an administrator and firewall should be opened up.
Is working fine for me with FireFox 12.0.
Which version are you using?
Re: HMGSCRIPT 2012: Programming For The Web in The Right Way
Posted: Sat Jun 02, 2012 12:14 pm
by Rathinagiri
Sorry I am using FireFox 10. I will update now and check.
Re: HMGSCRIPT 2012: Programming For The Web in The Right Way
Posted: Sat Jun 02, 2012 12:17 pm
by Roberto Lopez
rathinagiri wrote:Now, my basic doubts:
1. Can wssocket server be started in a Linux machine.
2. Can we make it run in a leased web space provider's system? (for example, can I someway start wssocket server in our forum's server providers system?)
I have uploaded hmgscript in
hmgscript. So, we can test the behavior immediately.
R1: I guess yes, but I'm not tested. I've tweaked the command line, but you can look at the application and you'll find option to make it run as a daemon instead as a normal app.
R2: I don't know, but my first thinking is that is not possible, but I'm not sure. The alternative, as I've stated in a previous post is to use a PHP based websockets server. There is code available. Just google it.
Re: HMGSCRIPT 2012: Programming For The Web in The Right Way
Posted: Sat Jun 02, 2012 12:19 pm
by Roberto Lopez
Rossine wrote:Hi Roberto,
Wow
Thank you for being expanding our horizons
I work for many years with HRB. What do you need ?
Below an example of how to put generate it and run it.
Thanks!
My idea is to pass message to the server with the name of external .hrb modules to execute, so there will be no need to recompile the whole server when you want to add or modify a module.
I'll start testing.
Re: HMGSCRIPT 2012: Programming For The Web in The Right Way
Posted: Sat Jun 02, 2012 12:22 pm
by Rossine
Hi Roberto,
Here a more detailed example:
Code: Select all
#include "hbcompat.ch"
function MAIN
local CONTEUDO, nHandle
cls
CREATES_NEWHRB()
CONTEUDO := HRB_LoadFromFileEncrypted( "myhrb.hrb", "mypassword" )
try
nHandle := hb_hrbload( CONTEUDO )
catch oErr
? "Error load in hrb"
quit
end
if empty( nHandle )
? "Error call hrb"
quit
endif
? call_func( nHandle, "p1", "1" )
? call_func( nHandle, "p2", "2" )
hb_hrbunload( nHandle )
return NIL
*************************
static function call_func( nHandle, cFunc, xPar )
*************************
local xRet := HB_HRBGETFUNSYM( nHandle, cFunc )
if empty( xRet )
? "Error load in function " + cFunc
quit
endif
return eval( xRet, xPar )
********************************
function HRB_SaveToFileEncrypted( cEncFileName, cKey, cHrbBody )
********************************
local cFile
if !empty( cHrbBody )
cHrbBody := hb_zcompress( cHrbBody )
cHrbBody := sx_encrypt( cHrbBody, cKey )
hb_memowrit( cEncFileName, cHrbBody )
endif
return NIL
**********************************
function HRB_LoadFromFileEncrypted( cFile, cKey )
**********************************
local cHrbBody
cHrbBody := hb_memoread( cFile )
cHrbBody := sx_decrypt( cHrbBody, cKey )
cHrbBody := hb_zuncompress( cHrbBody )
return cHrbBody
***********************
function CREATES_NEWHRB
***********************
local CONTENT, HANDLE_HRB, PRG, HRBCODE
PRG := ;
"function p1( cPar )" + hb_eol() + ;
"? 'Hello World One ' + cPar" + hb_eol() + ;
"return 'One'" + hb_eol() + ;
"function p2( cPar )" + hb_eol() + ;
"? 'Hello World Two ' + cPar" + hb_eol() + ;
"return 'Two'"
HRBCODE := hb_compileFromBuf( PRG, "harbour", "-n", "-w3", "-es2", "-q0" )
HRB_SaveToFileEncrypted( "myhrb.hrb", "mypassword", HRBCODE )
RETURN
Best Regards,
Rossine.