Page 1 of 2

syntax: Xbase (old HMG3) and OOP (new HMG4)

Posted: Mon Jul 04, 2011 3:38 pm
by l3whmg
Hi friends.
I was applying the solution to the problem when you press ENTER, when I noticed a lot of problems inside "HMG.ch".

I will give you an example: TEXTBOX. Within "HMG.CH" I can find this:

Code: Select all

DEFINE TEXTBOX <oObj>..... => With Object <oObj> := TEXTBOX():New( <"oObj">..........
I think, this code it's wrong. The right is:

Code: Select all

DEFINE TEXTBOX <oObj> ..... => With Object TEXTBOX():New( <"oObj">..........
Why is this right?
1) With use of switch "/w3" (Harbour compiler) you can find a lot of errors: many var are undeclared and so on. With "/w0", obviously, no errors but not every time.
2) Because with XBase (old HMG3) we have this syntax: FormName.ControlName.Value and not ControlName.Value And the first syntax do it.
3) On the other hand, with HMG4 parent system, we can use "FormName:ControlName:Value" without problem. I've tested.

So, in my program I write:

Code: Select all

DEFINE TEXTBOX NameOfTextbox
....
END TEXTBOX
without the need to clarify "NameOfTextbox" as a var.

If I write with OOP (new HMG4) syntax, the problem is different, because I apply directly the OOP syntax to my program:

Code: Select all

WITH OBJECT NameOfTextbox := TEXTBOX():New()
........
END WITH
I must manage "NameOfTextbox" as "public", "local" or "private" as I like it.

It's my mystake/misunderstanding? What do you think?
I can clean "HMG.ch" before a commit, but I want your opinion.

Best regards

Re: syntax: Xbase (old HMG3) and OOP (new HMG4)

Posted: Mon Jul 04, 2011 5:37 pm
by mrduck
l3whmg wrote:I can clean "HMG.ch" before a commit, but I want your opinion.
Luigi, the good part of using svn is that we can always revert a change if necessary.... I don't think there are problems since New( oObj... takes care of creating the data member oObj... there are of cource exceptions as I told you pm, for example when we want to use class members as objects:
DEFINE TEXTEDIT ::myTextEdit <-- this won't work
DEFINE TEXTEDIT otherWindow:myTextEdit <-- this won't work
WITH OBJECT otherWindow:myTextEdit := TEXTEDIT():New() <-- this works

Re: syntax: Xbase (old HMG3) and OOP (new HMG4)

Posted: Mon Jul 04, 2011 5:47 pm
by l3whmg
Hi Mrduck.
I can in agreement with you, but when I try to compile demos (I'm using /w3) I receive a lot of warnings / errors.
Why? Because HMG.ch have "With Object <oObj> := ...." and source program don't handle vars.
I can leave this syntax: no problem for me.

Cheers.

P.S. all fine your weekend?

Re: syntax: Xbase (old HMG3) and OOP (new HMG4)

Posted: Mon Jul 04, 2011 5:52 pm
by mrduck
You can proceed with the changes, if a problem will arise we will revert the change
l3whmg wrote: P.S. all fine your weekend?
Bad weather now... I'm at the notebook :-)

Re: syntax: Xbase (old HMG3) and OOP (new HMG4)

Posted: Mon Jul 04, 2011 6:02 pm
by concentra
Hi Luigi.
l3whmg wrote:FormName:ControlName:Value" without problem. I've tested.
And we loose the option to reference ControlName:Value.
Sounds bad to me.
In my opinion, defining vars is a programmers problem, not HMG.
If one needs /w3 he must take care of this.

P.S. I use -es2 in all my code and if a var is not defined it rises a compilation error !

Re: syntax: Xbase (old HMG3) and OOP (new HMG4)

Posted: Mon Jul 04, 2011 7:08 pm
by l3whmg
Hi Mauricio.
Ok, I understand :mrgreen: There are a lot of reason to leave this!
On the other hand there are other problem (ie menu) and /w3 can't used.
Anyway, IMHO /w3 it's a good must to have clean source code.
Cheers

Re: syntax: Xbase (old HMG3) and OOP (new HMG4)

Posted: Tue Jul 05, 2011 12:30 pm
by concentra
Hi Luigi.
l3whmg wrote:On the other hand there are other problem (ie menu) and /w3 can't used.
I am revising the menus to finish the name in New() method work. And probably address this issue with menus and /w3.

But I have a doubt.
In hmg.ch, when a named menuitem is translated, the menuitem object is added ( AddData() ) to oCurrentWindow.
Is this OK ? Why the window ? Wouldn´t it be added to the menu this item is subordinated ?
Or is this the HMG3 way, so this is compatibility ?

Need to know this to finish the job.

Re: syntax: Xbase (old HMG3) and OOP (new HMG4)

Posted: Tue Jul 05, 2011 12:38 pm
by Rathinagiri
That is for HMG3 compatibility.

windowname.menuitemname.checked
windowname.menuitemname.enabled

Properties are being used.

Re: syntax: Xbase (old HMG3) and OOP (new HMG4)

Posted: Tue Jul 05, 2011 12:42 pm
by concentra
Hei, you are fast ! :mrgreen:
rathinagiri wrote:That is for HMG3 compatibility.
windowname.menuitemname.checked
windowname.menuitemname.enabled
Properties are being used.
So, I will preserve this compatibility, and it will also be possible to do windowname.menuname.menuitemname.checked ...

Re: syntax: Xbase (old HMG3) and OOP (new HMG4)

Posted: Tue Jul 05, 2011 1:47 pm
by concentra
Hi Luigi.
While testing demos I found a problem with C:\hmg.SVN\samples\label\demo_5.prg.
It tries to rename a window and the rename method calls DelData() and DelData() is from Basic class and HMGAPP does not inherit from Basic...
Could you please investigate ?
Thanks.