HRB V/S LIB

HMG Samples and Enhancements

Moderator: Rathinagiri

User avatar
luisvasquezcl
Posts: 996
Joined: Thu Jul 31, 2008 3:23 am
Location: Chile
Has thanked: 5 times
Been thanked: 10 times
Contact:

HRB V/S LIB

Post by luisvasquezcl » Wed Apr 12, 2017 7:14 pm

Estimados, retomando una inquietud que tuvo Vanguarda, me puse a investigar un poco con los archivos .hrb (mis agradecimientos a Fernando Chirico por la pista ) y me encuentro que son muy útiles a la hora de actualizar nuestros programas sin tener que enviar el ejecutable sino sólo las rutinas que fueron modificadas.
Para eso podemos usar los archivos .hrb en donde podremos generar todo el código necesario para que funcione nuestra aplicación.
Les dejo un ejemplo muy simple de como usar esta utilidad.
Como compilar el ejemplo

- Para generar el archivo .hrb
harbour.exe libreria.prg /gh

- Para compilar el ejecutable.

c:\hmg.3.4.3\build.bat test5.prg

espero les sea de utilidad o por lo menos para salir de curiosidad.
Saludos cordiales,
Luis Vasquez.
test5.zip
(734 Bytes) Downloaded 47 times
I use hmg3.4.3, please modify .bat files for your hmg version

Dear friends, returning to a concern that Vanguarda had, I started to investigate a bit with .hrb files (my thanks to Fernando Chirico for the track) and I find they are very useful when updating our programs without having to send the executable But only the routines that were modified.
For that we can use .hrb files where we can generate all the necessary code for our application to work.
I leave a very simple example of how to use this utility.
How to compile the example

- To generate the .hrb file
Harbour.exe libreria.prg / gh

- To compile the executable.

C: \ hmg.3.4.3 \ build.bat test5.prg

I hope it is useful or at least to get out of curiosity.
Best regards,
Luis Vasquez
test5.zip
(734 Bytes) Downloaded 47 times

User avatar
Pablo César
Posts: 4052
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 175 times

Post by Pablo César » Wed Apr 12, 2017 8:46 pm

Interesante. Gracias por compartir, Luis.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein

hmgaams57
Posts: 55
Joined: Mon Feb 27, 2017 10:00 am
Been thanked: 1 time
Contact:

Post by hmgaams57 » Wed Apr 12, 2017 10:59 pm

Thanks for sharing. Said

User avatar
serge_girard
Posts: 1727
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 218 times
Been thanked: 37 times
Contact:

Post by serge_girard » Thu Apr 13, 2017 6:51 am

Thanks Luis !

The commands however should be:

BUILDEXE TEST5.PRG
BUILDHRB LIBRERIA.PRG

Serge

User avatar
mol
Posts: 2740
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 91 times
Been thanked: 31 times
Contact:

Post by mol » Thu Apr 13, 2017 7:20 am

Interesting!

User avatar
serge_girard
Posts: 1727
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 218 times
Been thanked: 37 times
Contact:

Post by serge_girard » Thu Apr 13, 2017 7:58 am

Actually this means that we can stuff libreria.prg with all kinds of UDF and call them from any PRG as long as libreria.hrb is present somewhere.
Sounds very usefull. Once program test5 is compiled you can modify/upgrade libreria.prg/hrb.

Serge

User avatar
gfilatov
Posts: 502
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Has thanked: 5 times
Been thanked: 32 times
Contact:

Post by gfilatov » Thu Apr 13, 2017 10:12 am

serge_girard wrote:
Thu Apr 13, 2017 7:58 am
Actually this means that we can stuff libreria.prg with all kinds of UDF and call them from any PRG as long as libreria.hrb is present somewhere.
Sounds very usefull. Once program test5 is compiled you can modify/upgrade libreria.prg/hrb.
Hello Serge,

Please note that we can generate an encrypted HRB file at runtime also.

Take a look for the following sample from the MiniguiEx distribution:

Code: Select all

#include "hmg.ch"

PROCEDURE Main

   DEFINE WINDOW Win_Main ;
	AT 0,0 ;
	WIDTH 600 ;
	HEIGHT 400 ;
	TITLE 'Harbour Script Usage Demo' ;
	MAIN ;
	FONT 'Times New Roman' SIZE 12

	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 cCONTENT, hHANDLE_HRB, cPRG, cHRBCODE
   LOCAL cFILE := "script.hrb", cPASSWORD := "MyPasswordKey"

   IF !FILE( cFILE )

      cPRG := ;
         "proc p()" + hb_eol() + ;
         "   SetProperty ( 'Win_Main', 'StatusBar' , 'Item' , 1 , 'Hello World!' ) " + hb_eol() + ;
         "   MsgInfo( 'Hello World!' )" + hb_eol() + ;
         "return"

      cHRBCODE := hb_compileFromBuf( cPRG, "harbour", "-n", "-w3", "-es2", "-q0" )

      MEMOWRIT( cFILE, sx_encrypt( cHRBCODE, cPASSWORD ) )

   ENDIF

   cCONTENT := sx_decrypt( MEMOREAD( cFILE ), cPASSWORD )

   hHANDLE_HRB := hb_hrbload( cCONTENT )

   hb_hrbDo( hHANDLE_HRB )

   hb_hrbunload( hHANDLE_HRB )

RETURN
Hope that useful :idea:
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein

User avatar
Anand
Posts: 167
Joined: Tue May 24, 2016 4:36 pm
DBs Used: DBF
Has thanked: 14 times
Been thanked: 27 times

Post by Anand » Thu Apr 13, 2017 10:23 am

Very good example of using scripts in HMG, thanks luisvasquezcl and gfilatov
Now we can add features to existing exe quickly and sent to client.

Regards,

Anand
Image

User avatar
serge_girard
Posts: 1727
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 218 times
Been thanked: 37 times
Contact:

Post by serge_girard » Thu Apr 13, 2017 10:53 am

Thanks Grigory ! Very interesting subject with much possibilities to discover!

Serge

User avatar
luisvasquezcl
Posts: 996
Joined: Thu Jul 31, 2008 3:23 am
Location: Chile
Has thanked: 5 times
Been thanked: 10 times
Contact:

Post by luisvasquezcl » Thu Apr 13, 2017 2:43 pm

Hola estimados, gracias por sus palabras. Cuando vi las posibilidades que nos ofrece el uso de los archivos .hrb como libreria me interesó mucho ya que tengo un programa que se debe actualizar cada cierto tiempo por temas legales y hay que ir a instalar el nuevo ejecutable por cada actualización y no es muy divertido.
Dejo abierto el tema para su investigación, aportes, comentarios y críticas por supuesto.
un saludos desde chile,
Luis Vasquez.

Hello dear, thank you for your words. When I saw the possibilities offered by the use of .hrb files as a library I was very interested because I have a program that must be updated from time to time by legal issues and you have to go install the new executable for each update and it is not very funny.
I leave the topic open for your research, input, comments and criticisms of course.
A greetings from chile,
Luis Vasquez.

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest