HMG 4 Started

Moderator: Rathinagiri

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: HMG 4 Started

Post by Rathinagiri »

Thanks for the advice Roberto.

Now I have changed the code/demo as per your instructions. Kindly check and tell me, so that I can proceed further.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
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: HMG 4 Started

Post by Rathinagiri »

Hi Roberto,

Is there a way for these two things as we have already used upto HMG 3?

1. How to define the events as we have done in semi-oop style.

For example, instead of win1:checkbox:value := .t. we have to use win1.checkbox1.value := .t.

2. Can we omit the code blocking characters?

For example:

define checkbox c
row 10
col 10
onchange checkboxchangefunction() // and not onchange {||checkboxchangefunction()}
caption "A Checkbox"
end checkbox
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
Roberto Lopez
HMG Founder
Posts: 4004
Joined: Wed Jul 30, 2008 6:43 pm

Re: HMG 4 Started

Post by Roberto Lopez »

rathinagiri wrote:Hi Roberto,

Is there a way for these two things as we have already used upto HMG 3?

1. How to define the events as we have done in semi-oop style.

For example, instead of win1:checkbox:value := .t. we have to use win1.checkbox1.value := .t.
It is automatically done via two 'tricks' already in place, so, you must do nothing.

The first one is that the control variable name (stringuified) is added as an instance variable to the control parent window, allowing this:

Window:Control:Property

This is done in the Create() method via the following line:

::oParent:AddData ( ::cName , Self )

It must be present in the Create() method for every control (AddData() is a method in Window class that do the thing).

The second one is the following directive in hmg.ch:

#xtranslate .<!msg!> => :<msg>

Allowing to write:

Window:Control:Property

As:

Window.Control.Property
rathinagiri wrote: 2. Can we omit the code blocking characters?

For example:

define checkbox c
row 10
col 10
onchange checkboxchangefunction() // and not onchange {||checkboxchangefunction()}
caption "A Checkbox"
end checkbox
We could do it 'blockifiying' it in #command definitions but, let me assure that this do not bring problems when you want to work with code blocks.

I'll do a definitive answer about that later.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
Roberto Lopez
HMG Founder
Posts: 4004
Joined: Wed Jul 30, 2008 6:43 pm

Re: HMG 4 Started

Post by Roberto Lopez »

rathinagiri wrote:Thanks for the advice Roberto.

Now I have changed the code/demo as per your instructions. Kindly check and tell me, so that I can proceed further.
This is it... It looks good!!!
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
Roberto Lopez
HMG Founder
Posts: 4004
Joined: Wed Jul 30, 2008 6:43 pm

Re: HMG 4 Started

Post by Roberto Lopez »

Roberto Lopez wrote:
It is automatically done via two 'tricks' already in place, so, you must do nothing.

The first one is that the control variable name (stringuified) is added as an instance variable to the control parent window, allowing this:

Window:Control:Property

This is done in the Create() method via the following line:

::oParent:AddData ( ::cName , Self )

It must be present in the Create() method for every control (AddData() is a method in Window class that do the thing).

The second one is the following directive in hmg.ch:

#xtranslate .<!msg!> => :<msg>

Allowing to write:

Window:Control:Property

As:

Window.Control.Property
And when you create a window using DEFINE WINDOW command its object variable is made public:

__MVPUBLIC ( <"oObj"> ) ;;

So, you can use the syntax:

Window.Control.Property

at any place of your application, exactly like standard HMG.

Please note that must use DEFINE WINDOW to achieve this since there is not pre-processing when you use raw objects (ie):

oWindow := Window:New()
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
sudip
Posts: 1454
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India

Re: HMG 4 Started

Post by sudip »

Hello,

TortoiseSVN works!
Testing samples now.
Then I shall go through souce code and understand.
Then I shall contribute from my side.

Sorry, I am slow this time :( (but I shall understand first)

Roberto, thanks for your explanation.
Rathi, as you said - I am also going to talk less more work ;) Thank you friend.

After 5 min:
In textbox sample 2 (demo_2.prg), I found following lines:

Code: Select all

		@ 10 , 40 TextBox Text1				;
			Width		200			;
			Value		'OOP TextBox 1 !!!'
So, I suppose Text1 has initial value 'OOP TextBox 1 !!!'. But, it is not shown and when I click on Button1, MsgInfo( Win1:Text1:Value ) shows blank. I suppose initialization of value property during textbox definition is will be added later. Am I correct?
With best regards,
Sudip
User avatar
sudip
Posts: 1454
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India

Re: HMG 4 Started

Post by sudip »

Roberto Lopez wrote: And when you create a window using DEFINE WINDOW command its object variable is made public:

__MVPUBLIC ( <"oObj"> ) ;;

So, you can use the syntax:

Window.Control.Property

at any place of your application, exactly like standard HMG.

Please note that must use DEFINE WINDOW to achieve this since there is not pre-processing when you use raw objects (ie):

oWindow := Window:New()
And when we write

Code: Select all

Local oWindow

	With Object oWindow := Window():New()
Here, oWindow is local. :)

Moreover ACTIVATE WINDOW command works with both local and public window object.
With best regards,
Sudip
User avatar
Roberto Lopez
HMG Founder
Posts: 4004
Joined: Wed Jul 30, 2008 6:43 pm

Re: HMG 4 Started

Post by Roberto Lopez »

sudip wrote:
After 5 min:
In textbox sample 2 (demo_2.prg), I found following lines:

Code: Select all

		@ 10 , 40 TextBox Text1				;
			Width		200			;
			Value		'OOP TextBox 1 !!!'
So, I suppose Text1 has initial value 'OOP TextBox 1 !!!'. But, it is not shown and when I click on Button1, MsgInfo( Win1:Text1:Value ) shows blank. I suppose initialization of value property during textbox definition is will be added later. Am I correct?
You are right. It must be added in Create() method at textbox.prg.

Regarding contributing I guess that the best way to go is that (at least for now) each contributor pick one control. ie: rathinagiri has took checkbox.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
sudip
Posts: 1454
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India

Re: HMG 4 Started

Post by sudip »

Hello,

I just noted a very interesting thing. Now we can use control object directly, without using window object :)

Code: Select all

With Object oWindow := Window():New()
...
		With Object oButton2 := Button():New()
			:Row		:= 140
			:Col		:= 40
			:Caption	:= 'Change Caption'
			:OnClick	:= { || oButton2:value := 'Caption Changed' }
		End With
...
oButton2:value := 'Caption Changed' :)
With best regards,
Sudip
User avatar
apais
Posts: 440
Joined: Fri Aug 01, 2008 6:03 pm
DBs Used: DBF
Location: uruguay
Contact:

Re: HMG 4 Started

Post by apais »

A changelog file in the main svn folder would be usefull =)
Angel Pais
Web Apps consultant/architect/developer.
Post Reply