About hmg3 and hmg4 compatibility

Moderator: Rathinagiri

mrduck
Posts: 497
Joined: Fri Sep 10, 2010 5:22 pm

About hmg3 and hmg4 compatibility

Post by mrduck »

One of the goal of hmg4 project is to allow hmg3 code to be easily ported to hmg4. This was repeteaded several times.

My first attempt to port a component not yet ported from hmg3 to 4 was (and actually is since it is far to be completed) a nightmare. But it was an internal component and so I thought is was normal that it would take a lot of effort.

Now I decided to port a sample project, found in hmg3 samples\agenda, since it uses a CHILD window and I wanted to check how this window behaves.

First compilation reports 17 errors.... I 'm just starting to see what these errors are about and what changes needs to be done to the code, if something is still missing in hmg4 or broken.... let's see what should be changed....

does anybody more proficient than me on hmg3 wants to join me on this exercise ?

Francesco

Code: Select all

Agenda.prg(86) Error E0030  Syntax error "syntax error at 'ITEM'"
Agenda.prg(89) Error E0030  Syntax error "syntax error at 'CONTROL'"
Agenda.prg(93) Error E0030  Syntax error "syntax error at 'WINDOW'"
Agenda.prg(107) Error E0030  Syntax error "syntax error at 'ITEM'"
Agenda.prg(110) Error E0030  Syntax error "syntax error at 'ITEM'"
Agenda.prg(142) Error E0030  Syntax error "syntax error at 'WINDOW'"
Agenda.prg(366) Error E0030  Syntax error "syntax error at 'WINDOW'"
Agenda.prg(377) Error E0020  Incomplete statement or unbalanced delimiters
Agenda.prg(401) Error E0030  Syntax error "syntax error at 'WINDOW'"
Agenda.prg(421) Error E0020  Incomplete statement or unbalanced delimiters
Agenda.prg(431) Error E0020  Incomplete statement or unbalanced delimiters
Agenda.prg(447) Error E0020  Incomplete statement or unbalanced delimiters
Agenda.prg(513) Error E0030  Syntax error "syntax error at 'CONTROL'"
Agenda.prg(516) Error E0020  Incomplete statement or unbalanced delimiters
Agenda.prg(601) Error E0030  Syntax error "syntax error at 'CONTROL'"
Agenda.prg(603) Error E0030  Syntax error "syntax error at 'WINDOW'"
Agenda.prg(614) Error E0030  Syntax error "syntax error at 'CONTROL'"
17 errors
mrduck
Posts: 497
Joined: Fri Sep 10, 2010 5:22 pm

Re: About hmg3 and hmg4 compatibility

Post by mrduck »

NOTE: the source code is in a state that it is impossible to compile and of course run, so what I'm reporting here are PROPOSALs that must be checked when the source code will finally compile and run.


Ok, some of the errors are from a missing #translate:
CENTER WINDOW Form_3

Probably it was missing due to the previous way of objects defining (objects created later) but now I think it is possible to translate it to
Form_3:center()
because Form_3 and it's underlying Qt object is created at the DEFINE.

down to 14 errors with no changes at the code

Code: Select all

Compiling 'Agenda.prg'...
Agenda.prg(86) Error E0030  Syntax error "syntax error at 'ITEM'"
Agenda.prg(89) Error E0030  Syntax error "syntax error at 'CONTROL'"
Agenda.prg(107) Error E0030  Syntax error "syntax error at 'ITEM'"
Agenda.prg(110) Error E0030  Syntax error "syntax error at 'ITEM'"
Agenda.prg(142) Error E0030  Syntax error "syntax error at 'WINDOW'"
Agenda.prg(377) Error E0020  Incomplete statement or unbalanced delimiters
Agenda.prg(401) Error E0030  Syntax error "syntax error at 'WINDOW'"
Agenda.prg(421) Error E0020  Incomplete statement or unbalanced delimiters
Agenda.prg(431) Error E0020  Incomplete statement or unbalanced delimiters
Agenda.prg(447) Error E0020  Incomplete statement or unbalanced delimiters
Agenda.prg(513) Error E0030  Syntax error "syntax error at 'CONTROL'"
Agenda.prg(516) Error E0020  Incomplete statement or unbalanced delimiters
Agenda.prg(601) Error E0030  Syntax error "syntax error at 'CONTROL'"
Agenda.prg(614) Error E0030  Syntax error "syntax error at 'CONTROL'"
14 errors
mrduck
Posts: 497
Joined: Fri Sep 10, 2010 5:22 pm

Re: About hmg3 and hmg4 compatibility

Post by mrduck »

Another class of problems....

look at this code

Code: Select all

If Empty( Form_2.T_Nome.Value )
  MsgINFO( "Nome não foi Informado!!" , "Agenda" )
  Form_2.T_Nome.SetFocus
  Return Nil
EndIf
hmg4 preprocessor translates to

Code: Select all

If Empty( Form_2:T_Nome:Value )
  MsgINFO( "Nome não foi Informado!!" , "Agenda" )
  Form_2:T_Nome:SetFocus
  Return Nil
EndIf
At compile time the compiler reports an error on :SetFocus... the :Value should be ok since it is a SETGET method.... should we transform SetFocus to a SETGET method ? Or go the preprocessor route ? Both won't work. The SETGET since we don't have the assignment part (the := <value> part) the second... well, I was not able to change Form_2:T_Nome:SetFocus to Form_2:T_Nome:SetFocus() in the preprocessor without creating a circular reference and breaking the compile...

So I now manually change SetFocus to SetFocus()... if anyone has an idea is welcome...

Code: Select all

agenda.prg(86) Error E0030  Syntax error "syntax error at 'ITEM'"
agenda.prg(89) Error E0030  Syntax error "syntax error at 'CONTROL'"
agenda.prg(107) Error E0030  Syntax error "syntax error at 'ITEM'"
agenda.prg(110) Error E0030  Syntax error "syntax error at 'ITEM'"
agenda.prg(142) Error E0030  Syntax error "syntax error at 'WINDOW'"
agenda.prg(401) Error E0030  Syntax error "syntax error at 'WINDOW'"
agenda.prg(421) Error E0020  Incomplete statement or unbalanced delimiters
agenda.prg(431) Error E0020  Incomplete statement or unbalanced delimiters
agenda.prg(513) Error E0030  Syntax error "syntax error at 'CONTROL'"
agenda.prg(601) Error E0030  Syntax error "syntax error at 'CONTROL'"
agenda.prg(614) Error E0030  Syntax error "syntax error at 'CONTROL'"
11 errors
mrduck
Posts: 497
Joined: Fri Sep 10, 2010 5:22 pm

Re: About hmg3 and hmg4 compatibility

Post by mrduck »

Do with <w>.Release what already done with .SetFocus

There are also some ACTION/codeblocks with .SetFocus and I changed them as well since they will probably create error at runtime.

down to 9 errors

Code: Select all

agenda.prg(86) Error E0030  Syntax error "syntax error at 'ITEM'"
agenda.prg(89) Error E0030  Syntax error "syntax error at 'CONTROL'"
agenda.prg(107) Error E0030  Syntax error "syntax error at 'ITEM'"
agenda.prg(110) Error E0030  Syntax error "syntax error at 'ITEM'"
agenda.prg(142) Error E0030  Syntax error "syntax error at 'WINDOW'"
agenda.prg(401) Error E0030  Syntax error "syntax error at 'WINDOW'"
agenda.prg(513) Error E0030  Syntax error "syntax error at 'CONTROL'"
agenda.prg(601) Error E0030  Syntax error "syntax error at 'CONTROL'"
agenda.prg(614) Error E0030  Syntax error "syntax error at 'CONTROL'"
9 errors
mrduck
Posts: 497
Joined: Fri Sep 10, 2010 5:22 pm

Re: About hmg3 and hmg4 compatibility

Post by mrduck »

There are some commands of the type:

Code: Select all

MODIFY CONTROL Edit_1 OF Form_3 FONTSIZE nFont
in hmg3 is

Code: Select all

#translate MODIFY [ PROPERTY ] [ CONTROL ] <Arg2> OF <Arg1> <Arg3> <Arg4> ;
=> ;
SetProperty ( <"Arg1"> , <"Arg2"> , <"Arg3"> , <Arg4> )
(set/getProperty... mmm....)

Let's see if we can transform in:

Code: Select all

Form_2:Edit_1:fontsize := nFont

This translate takes care of it:

Code: Select all

#translate MODIFY [ PROPERTY ] [ CONTROL ] <Arg2> OF <Arg1> <Arg3> <Arg4> ;
=> ;
<Arg1>:<Arg2>:<Arg3> := <Arg4>
in hmg3 i_controlmisc.ch there are some other combinations of this translate so we should also port them....

down to 5 errors

Code: Select all

agenda.prg(86) Error E0030  Syntax error "syntax error at 'ITEM'"
agenda.prg(107) Error E0030  Syntax error "syntax error at 'ITEM'"
agenda.prg(110) Error E0030  Syntax error "syntax error at 'ITEM'"
agenda.prg(142) Error E0030  Syntax error "syntax error at 'WINDOW'"
agenda.prg(401) Error E0030  Syntax error "syntax error at 'WINDOW'"
5 errors
mrduck
Posts: 497
Joined: Fri Sep 10, 2010 5:22 pm

Re: About hmg3 and hmg4 compatibility

Post by mrduck »

RELEASE WINDOW ALL is the correct way to close application in hmg3. I just translate it to QUIT

Code: Select all

#command RELEASE WINDOW ALL  ;
   =>;
   quit
down to 3 errors...
Last edited by mrduck on Wed Jul 27, 2011 11:09 am, edited 1 time in total.
mrduck
Posts: 497
Joined: Fri Sep 10, 2010 5:22 pm

Re: About hmg3 and hmg4 compatibility

Post by mrduck »

command like

Code: Select all

ADD ITEM { CHR(i+64) } TO GIndice OF Form_1
added

Code: Select all

#command ADD ITEM <i> TO <n> OF <p> ;
   =>;
   <p>:<n>:addItem( <i> )
down to 1 error
mrduck
Posts: 497
Joined: Fri Sep 10, 2010 5:22 pm

Re: About hmg3 and hmg4 compatibility

Post by mrduck »

Last command to be converted:

Code: Select all

DELETE ITEM ALL FROM Grid_Agenda OF Form_1
In hmg3

Code: Select all

#command DELETE ITEM ALL FROM <n> OF <p>;
   =>;
   DoMethod ( <"p"> , <"n"> , 'DeleteAllItems' )
In hmg4

Code: Select all

#command DELETE ITEM ALL FROM <n> OF <p> ;
   =>;
   <p>:<n>:deleteAllItems( )


now we have 0 compile errors... but one link error:
undefined reference to `HB_FUN_GETCONTROLTYPE'
mrduck
Posts: 497
Joined: Fri Sep 10, 2010 5:22 pm

Re: About hmg3 and hmg4 compatibility

Post by mrduck »

GetControlType in hmg3 is a function and it is ok in the hmg3 semi-oop style...

Code: Select all

Function GetControlType (ControlName,ParentForm)
Done that, now is the line

Code: Select all

   aRet := GetProperty (  ParentForm  , ControlName , 'Item' , GetProperty( ParentForm , ControlName , 'Value' ) )
that doesn't work since hmg4 implementation has only 3 parameters.... I'm trying to understand what this line wants to get... do you how to translate it in hmg4 ?
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: About hmg3 and hmg4 compatibility

Post by Rathinagiri »

I am sure you have done a wonderful work here Francesco. I have tried one of my projects and could get it compiled with minimal changes.

I use standard calls to HMG and use MainWindow and several ModalWindows only. No other window types. I will post the project here.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
Post Reply