About HMG.4 Samples...

Moderator: Rathinagiri

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

Re: About HMG.4 Samples...

Post by mrduck » Wed Nov 30, 2011 7:03 am

rathinagiri wrote: For example, window.activate is ok in HMG3. But we have to put window.activate(), I think.
No, you don't have to add the () if you #define HMG3 since in hmg3.ch the conversion will be taken care of.

There are some still missing but I need someone tries to compile his own code, report the error, we can do the change, commit and the person has to verify that the behaviour is correct...


So, depending how you wrote the program it may be easier or difficult...

User avatar
Rathinagiri
Posts: 5264
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 169 times
Been thanked: 172 times
Contact:

Post by Rathinagiri » Wed Nov 30, 2011 7:12 am

:) Thanks for the info Francesco. It shows that we have many misconceptions regarding HMG 4.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.

User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Post by l3whmg » Wed Nov 30, 2011 12:18 pm

Hi Roberto.

About samples: I'm in agreement with you but remember that, all of these samples, was writed to check objects (working / not working and so on) and who written (or changed) some samples, perhaps he doesn't has good knowledge about HMG3.
I started to write "alldemo" with OOP style only to check and use objects; when finished, I want to translate with command line.

I write my POW some times ago about samples, OOP and command line.

Cheers

P.S. mee to in agreement to organize in a different way but I dont know if it's good to have different folders.
IMHO,
samples/textbox/demo01_op.prg (OOP, I think real OOP)
samples/textbox/demo01_cl.prg (command line)
and both "demo01" must do the same things....
Luigi from Italy
www.L3W.it

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

Post by mrduck » Wed Nov 30, 2011 12:44 pm

l3whmg wrote: samples/textbox/demo01_op.prg (OOP, I think real OOP)
samples/textbox/demo01_cl.prg (command line)
and both "demo01" must do the same things....
I agree with this position. directory must be one and demos different only for coding style must have different suffix.

So everyone can learn OOP just comparing the code...

Francesco

User avatar
Roberto Lopez
HMG Founder
Posts: 3980
Joined: Wed Jul 30, 2008 6:43 pm
Has thanked: 27 times
Been thanked: 168 times

Post by Roberto Lopez » Wed Nov 30, 2011 3:13 pm

rathinagiri wrote:Very nice idea indeed, Roberto.

I am sure at least ( or even none at all ) changing some lines of our existing code, we can port all our programs of HMG3 to HMG4.

For example, window.activate is ok in HMG3. But we have to put window.activate(), I think. There is no need for much of code change, this can be done with a program editor with a simple find and replace.
If you build using 'buildapp.bat /3' and add to it the new command SET COMPATIBLE ON you'll obtain better compatibility (check the last IDE release).
Regards/Saludos,

Roberto


(Veritas Filia Temporis)

User avatar
Roberto Lopez
HMG Founder
Posts: 3980
Joined: Wed Jul 30, 2008 6:43 pm
Has thanked: 27 times
Been thanked: 168 times

Post by Roberto Lopez » Wed Nov 30, 2011 4:13 pm

l3whmg wrote:Hi Roberto.

About samples: I'm in agreement with you but remember that, all of these samples, was writed to check objects (working / not working and so on) and who written (or changed) some samples, perhaps he doesn't has good knowledge about HMG3.
I started to write "alldemo" with OOP style only to check and use objects; when finished, I want to translate with command line.

I write my POW some times ago about samples, OOP and command line.
Many of the semi-oop samples, must be corrected too, but we must reach some kind of agreement about some details, prior to do it.

Some of them has the windows variables declared as local. ie in this sample:

Code: Select all

#include "hmg.ch"

FUNCTION Main

   LOCAL oWindow

   HbQt_ErrorSys()


   DEFINE MAINWINDOW oWindow
      ROW     10
      COL     10
      WIDTH   400
      HEIGHT  400
      TITLE   'Nice OOP Demo!!!'
      ONINIT  oWindow:Center()
      ONINTERACTIVECLOSE MsgYesNo( "bye?", "OnInteractiveClose" )
      ONRELEASE testOnRelease()
      WININTERACTIVECLOSE QUERY

   END WINDOW

   ACTIVATE WINDOW oWindow

   RETURN NIL

/*----------------------------------------------------------------------*/

FUNCTION testOnRelease()

   Msgstop( "test OnRelease", "OnRelease" )

   RETURN 0

Part of the basics of semi-oop model is that the window objects are public and there is no need to care about its scope, being accessible from anywhere on the app (exactly like a workarea).

This is the reason because the DEFINE WINDOW commands, uses the __MVPUBLIC() function to declare window object variable.

The problem is that when -w3 flag was added at build process, the semi-oop samples stopped compiling and then, they were 'fixed' adding a (ie) LOCAL declaration for a variable that will be created as public by the DEFINE WINDOW command.

To keep semi-oop model as clean as always was in HMG we must get rid of the variable declarations for windows and the hbqt_errorsys() mandatory call at the app start.

Such things makes HMG.4 look bad to many HMG3 users.

Any ideas about this?
l3whmg wrote: P.S. mee to in agreement to organize in a different way but I dont know if it's good to have different folders.
IMHO,
samples/textbox/demo01_op.prg (OOP, I think real OOP)
samples/textbox/demo01_cl.prg (command line)
and both "demo01" must do the same things....
I guess that both ways should be in place.

I mean, a separate folder with semi-oop samples only and 'twin' oop/semi-oop samples together for testing, comparison and learning.

I'll continue with this in my answer to Francesco...
Regards/Saludos,

Roberto


(Veritas Filia Temporis)

User avatar
Roberto Lopez
HMG Founder
Posts: 3980
Joined: Wed Jul 30, 2008 6:43 pm
Has thanked: 27 times
Been thanked: 168 times

Post by Roberto Lopez » Wed Nov 30, 2011 4:52 pm

mrduck wrote:
l3whmg wrote: samples/textbox/demo01_op.prg (OOP, I think real OOP)
samples/textbox/demo01_cl.prg (command line)
and both "demo01" must do the same things....
I agree with this position. directory must be one and demos different only for coding style must have different suffix.

So everyone can learn OOP just comparing the code...

Francesco
Francesco,

At first, I want to empathize that this is no my intention to start a flame about this.

I'm only trying to discuss ideas. It is a funny and productive thing.

Sadly, sometimes the written words meaning is misunderstood, but, since it is not possible for us to drink a coffee together and talk about this in person, I'm making this clarification :)

Many times, across almost 10 years of HMG development, many people wanted to 'educate' HMG users (and to me too) because our 'wrong' way of coding...

Well... semi-oop model is not wrong. It is an alternative way of coding.

So, the HMG users must not be 'educated' in OOP to correct their incorrect programming behavior :).

The people that selected HMG, done so, because it is simpler, cleaner and easier than standard OOP.

If we want to keep them with us, we must show them, how well HMG.4 is doing with semi-oop and how powerful is, comparing it with previous versions.

So, as mentioned in my previous post, my proposition is to have both things:

1. 'Twin' oop/semi-oop samples together for testing, comparison and OOP learning (for those HMG users interested on that).

2. A Separate folder with semi-oop samples only for those users that prefers semi-oop for your applications and are not interested on dealing with standard OOP.

Please remember that such 'mix' of samples is the main reason about users confusion about semi-oop support in HMG.4.

A separate/clean place for the samples, with polished semi-oop code, will solve the problem...
Regards/Saludos,

Roberto


(Veritas Filia Temporis)

User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Post by l3whmg » Wed Nov 30, 2011 4:55 pm

Hi Roberto
Roberto Lopez wrote:FUNCTION Main
LOCAL oWindow
HbQt_ErrorSys()
DEFINE MAINWINDOW oWindow
and a lot of other samples (OOP and semi-OOP) must be fixed (as Esgici write here). If you take a look within HmgForum and Changelog file, many times I fix and clean more samples and some times I ask help to do.....
This and other "errors" (please note ") because HMG4 was "changed" and "revised" in basis methods or usage; for example, I remember to you about [TO VAR...] option.

IMHO, about -w3 option I think must be always used because keep "clean" source code. Many times I write: "I think usage of shared vars to solve compilation problem it's not good". For example, with HMG3, in my program I add "MEMVAR _HMG_SYSDATA" to compile with -w3 option.
__MvPublic is a way but, in my opinion, out of Harbour behaviour regarding vars. Please follow the reasoning, not the meaning of individual words ;)

About "unique" folder: I think everyone can see two styles (programs must do the "same" things), learn and choose. At the same times, we can do a parallel test. This is my little opinion.

n.b. posted later your answer to Francesco

Cheers
Luigi from Italy
www.L3W.it

Ricci
Posts: 255
Joined: Thu Nov 19, 2009 2:23 pm

Post by Ricci » Wed Nov 30, 2011 4:59 pm

Roberto Lopez wrote: Part of the basics of semi-oop model is that the window objects are public and there is no need to care about its scope, being accessible from anywhere on the app (exactly like a workarea).

Any ideas about this?
Using windows as application-wide public can get you in trouble if you are working with MDI windows.

Imagine you have a function that opens a non-modal window. Now you can work in both windows. If you call the funtion again to open a 3rd window you may get in trouble assigning a public name for the window because the name still exist.

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

Post by mrduck » Wed Nov 30, 2011 5:46 pm

Roberto,
I officially invite you for a dinner if you will come in Rome, Italy. I work in the city center, short distance from Trevi's fountain. If any of you ever comes in Rome please tell and we will arrange a lunch/dinner...

that said, I want to specify that I'd like that similar sample code, only coded in the 3 different allowed syntaxes are kept together, like a modern "rosetta stone"!

More than one person said that he wants to learn by example. This is the only way (I think, we are discussing and mine was just a proposal) to compare and decide which syntax to use.
For example now esgici loves semi oop syntax. HMG4 supports it and he can continue to use it as he likes. But I'd also like if he could have the opportunity to easily check how the oop syntax is very very similar... and the file being in the same directory may help a lot. Do you think it will be confusing... ok, we may split in 3 different subdirs:
samples/xbase
samples/semioop
samples/oop
the actual samples/* dirs should all be moved to samples/mixed and then checked, tested and moved one by one to the proper dir, with the exact same name.

Really an heavy work...


...anyway, I said what is my preference, since I may be considered an evangelist of the OOP syntax... :-)

I'd like also to point to Luigi alldemo work. It is also hard work, and very useful since:
- every object has its form, so source code is easy to extract and read, it is not mixed as in everything demo
- every object is tested

Post Reply