HRB V/S LIB

HMG Samples and Enhancements

Moderator: Rathinagiri

User avatar
luisvasquezcl
Posts: 1258
Joined: Thu Jul 31, 2008 3:23 am
Location: Chile
Contact:

HRB V/S LIB

Post by luisvasquezcl »

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 309 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 309 times
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Re: HRB V/S LIB

Post by Pablo César »

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: 129
Joined: Mon Feb 27, 2017 10:00 am

Re: HRB V/S LIB

Post by hmgaams57 »

Thanks for sharing. Said
User avatar
serge_girard
Posts: 3161
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: HRB V/S LIB

Post by serge_girard »

Thanks Luis !

The commands however should be:

BUILDEXE TEST5.PRG
BUILDHRB LIBRERIA.PRG

Serge
There's nothing you can do that can't be done...
User avatar
serge_girard
Posts: 3161
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: HRB V/S LIB

Post by serge_girard »

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
There's nothing you can do that can't be done...
User avatar
gfilatov
Posts: 1060
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: HRB V/S LIB

Post by gfilatov »

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: 595
Joined: Tue May 24, 2016 4:36 pm
DBs Used: DBF

Re: HRB V/S LIB

Post by Anand »

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
Regards,

Anand

Image
User avatar
serge_girard
Posts: 3161
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: HRB V/S LIB

Post by serge_girard »

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

Serge
There's nothing you can do that can't be done...
User avatar
luisvasquezcl
Posts: 1258
Joined: Thu Jul 31, 2008 3:23 am
Location: Chile
Contact:

Re: HRB V/S LIB

Post by luisvasquezcl »

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