Page 3 of 16

HMG FMG Editor

Posted: Wed Apr 23, 2014 11:20 am
by Pablo César
Thank you Rathi for your interest and support.
Rathinagiri wrote:IMHO, menus, toolbars, contextmenus need not be shown in the preview itself.
Yes, probably do not is not needed to be displayed or maybe do not need to interact with it. Just to be displayed and that so. Because would be useful to display all components just to give to developer a better idea of spaces on.
Developers using .fmg are not going to open .fmg in text format and modify them. So, IMHO, the fmg files need not be human readable.
But we know most of us re-edit fmg files and change carefully just to reach with ideal result when IDE it is hard to thread for. Anyway reading fmg is subject to fail components and its properties for this reason.
In other words, you can use internal function calls like _hmg_sysdata[] which can be easy to manage.
Yes, I would like to use this. But how can I open a form when its fmg is variable and seems it is needing to compile thru #Include fmg :?:

My best question is: how our IDE makes with opening fmg files :?:

HMG FMG Editor

Posted: Thu Apr 24, 2014 2:58 pm
by Pablo César
It was almost two days... but I got it !!

I mean to load fmg file and execute it. At least is loading variable forms. So I need to make tests with all components...

Soon as possible, I will present to you my solution.

I am very happy !! :D

Now we can access directly by HMG system resources (more safe and correct) not by strings and substrings (and try not reinventing the wheel...) :P

I love Harbour, I love HMG !!!
            Image

Re: FMG Editor

Posted: Thu Apr 24, 2014 4:26 pm
by Javier Tovar
Pablo César wrote:It was almost two days... but I got it !!

I mean to load fmg file and execute it. At least is loading variable forms. So I need to make tests with all components...

Soon as possible, I will present to you my solution.

I am very happy !!

Now we can access directly by HMG system resources (more safe and correct) not by strings and substrings (and try not reinventing the wheel...)

I love Harbour, I love HMG !!!
            
Gracias Pablo César por tu esfuerzo y dedicación!!! :D :D :D

Felicidades :D :D :D

Re: FMG Editor

Posted: Thu Apr 24, 2014 5:24 pm
by Rathinagiri
Good going Pablo.

Re: FMG Editor

Posted: Thu Apr 24, 2014 5:51 pm
by mol
Wow! I'm waiting for your solution!

FMG Editor

Posted: Thu Apr 24, 2014 7:24 pm
by Pablo César
Thank you guys for your kind of words ! :D

I did not finished my started code in FMG_Editor with this new resources but I will try to explain to all of you.

We know for loading fmg file we use this:

Code: Select all

#include <hmg.ch>

Function Main
Load Window Main
Main.Center
Main.Activate
Return Nil
The main problem was this Main given at Load, Center and Active the window MUST be the same name of fmg file and also MUST be compiled whit name already declared. And we want this name shall be variable name, because user needs to choose fmg file and NOT as fixed name.

So I made from begining with this basis idea and I prepared this example:

Code: Select all

/*
  Demo0.prg to loading a form thru a string command
  Author: Pablo César Arrascaeta
  Date: Abril 24th, 2014
*/

#include <hmg.ch>

Function Main
DECLARE WINDOW Form_1
    Exe_Fmg1()
Form_1.Center
Form_1.Activate
Return Nil

Function Exe_Fmg1()
DEFINE WINDOW Form_1 AT 138 , 235 WIDTH 550 HEIGHT 350 TITLE "Loading Manually" ICON NIL MAIN
END WINDOW
Return Nil
I saw that calling function can be DEFINE WINDOW normally but is needing been with form name already and WINDOWTYPE correctlly, in this case must be MAIN.

In my previous tests, I garantee to read fmg file line by line, because the fmg is text file type and assigned to array which it makes easier processing. So I take line by line and these lines should be treated in order to know:

- Rename TEMPLATES to <NewFormName>
- Add or correct the WindowType
- Concatenate multi-lines which could cointains ";" (line break characters) and let it as one command line.

I take each line and step by routine interpreting the sequence of commands (by __PP_ Harbour functions) for the proper function according i_window.ch. After this new string result I read and execute thru hb_compileFromBuf and hb_hrbDo from Harbour functions again.

By words, I know is hard to understand, so I make available an example to your understanding:

Code: Select all

/*
  Demo1.prg for loading a form thru a string command at Runtime
  Author: Pablo César Arrascaeta
  Date: Abril 24th, 2014
*/

#include <hmg.ch>

REQUEST __PP_STDRULES

Function Main
DECLARE WINDOW Form_1
    // Exe_Fmg1()
    Exe_Fmg2()
Form_1.Center
Form_1.Activate
Return Nil

Function Exe_Fmg1()
DEFINE WINDOW Form_1 AT 138 , 235 WIDTH 550 HEIGHT 350 TITLE "" ICON NIL MAIN
END WINDOW
Return Nil

Function Exe_Fmg2()
Local cCommand, pPP

cCommand:='DEFINE WINDOW Form_1 AT 138 , 235 WIDTH 550 HEIGHT 350 TITLE "Stracted from FMG and putted manually" ICON NIL MAIN'
// pPP := __PP_INIT() // So it is not interpreted as HMG commands
pPP := __PP_INIT("C:\HMG.3.2\INCLUDE","i_window.ch")  // Here we can regulize with function extracting HMG path
cResult:=__PP_Process( pPP, cCommand )
If !Empty(cResult)
   Exe_Function(cResult)
Endif
cCommand:="END WINDOW"
cResult:=__PP_Process( pPP, cCommand )
If !Empty(cResult)
   Exe_Function(cResult)
Endif
Return Nil

Function Exe_Function(cCommand)
Local cPrg := "Function Run_PP()" + CRLF + ;
              cCommand + CRLF + ;
              "Return Nil"

HRBCODE := hb_compileFromBuf( cPrg, "harbour", "-n", "-w3", "-es2", "-q0" )
HANDLE_HRB := hb_hrbload( HRBCODE )
hb_hrbDo( HANDLE_HRB )
hb_hrbunload( HANDLE_HRB )
Return Nil
So in this example, is still not reading from fmg file, but this is not the problem. The important is to be understood the procedures. You will see in source code above, a little complicated but it's working and was hard for me to find out. I made of this all alone... As far it is, I do not like to give up so easily and I wish to share with all of you.

From the beginning, I thought I was not the wiser way ... I suspected having to assemble various routines that could recognize each component. It was absurd, since it already existed within the HMG.

Now basically you can understand how it was done a dribble this question. Of course this routine is only to define the WINDOW and do miss to recognize the remaining components, but believe it will be very easy to do it too.

Now I want to continue to make it calmly and I want to ask to you my apologize for I had given the news and not post the code immediately. It is because my motivation to keep doing tests and let it ready as cleanest code, so I'll need more time.

Now I know I'm on the right track !

In view of what has already been discovered and explained, I think Rathi + Claudio, we can incorporated these functions for loading fmg files with a new option, something like this:

WINDOW LOAD FROM <fmgname> AS <alias_form_name> WINDOWTYPE <Main/Child/..>

And add to the i_window.ch file to benefit everybody with over this feature. Of course, if this is approved by Roberto and the team of contributors HMG project.

What do you think ?

FMG Editor

Posted: Thu Apr 24, 2014 7:37 pm
by Pablo César
Imaging n function Exe_Fmg2() the cCommand variable it is coming from another routine which passing line by line. This was simulating string macro compiler execution.

Re: FMG Editor

Posted: Thu Apr 24, 2014 7:43 pm
by Javier Tovar
Hola Pablo César,

En verdad me sorprendes, estas funciones tan "Chiquitas" pero tan poderosas! :D :D :D

Saludos

P.D.: Solo un mago hace esto!

FMG Editor

Posted: Thu Apr 24, 2014 7:48 pm
by Pablo César
Pablo César wrote:In view of what has already been discovered and explained, I think Rathi + Claudio, we can incorporated these functions for loading fmg files with a new option, something like this:

WINDOW LOAD FROM <fmgname> AS <alias_form_name> WINDOWTYPE <Main/Child/..>

And add to the i_window.ch file to benefit everybody with over this feature. Of course, if this is approved by Roberto and the team of contributors HMG project.

What do you think ?
This new feature that maybe all we will have it, have a different issue to the current HMG standard. Because there is no need to recompile the program each time the fmg file is changed. I do not know if this is an advantage or a disadvantage this...

We'll have to evaluate that. :|

FMG Editor

Posted: Thu Apr 24, 2014 7:53 pm
by Pablo César
Javier Tovar wrote:En verdad me sorprendes, estas funciones tan "Chiquitas" pero tan poderosas!

..//..

P.D.: Solo un mago hace esto!
Me haces reir amigo... :lol:

Es el poder que tenemos en nuestras manos: Harbour y HMG. Mejor todavia, todo open source !! ;)

Cuanto al resumen de las funciones, es de acuerdo cada uno. Trabajar de forma organizado y limpio (me refiero al código) irá siempre ser mejor para el buen entendimiento y funcionabilidad. Busco siempre, crear funciones de acuerdo cada objetivo y coloco nombres que me hagan acordar de que se trata, asi no me pierdo en el código y no queda tan repetitivo ciertas rotinas.

Gracias Javier por tus consideraciones.
Eso me insentiva a crear cosas nuevas cuando los amigos demuestran cierto aprecio... :D