HMG Create object

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
miszler.zoltan
Posts: 22
Joined: Sun May 26, 2013 12:37 pm
Location: Hungary
Contact:

HMG Create object

Post by miszler.zoltan »

Hello guys!

The following structure could achieve what way?

myCar = new Object()
myCar.make = "Ford"
myCar.model = "Mustang"
myCar.year = 1969

MsgInfo( 'My Car: ' + myCar.make +' '+ myCar.model )

Best regards, Zoltan
User avatar
mustafa
Posts: 1158
Joined: Fri Mar 20, 2009 11:38 am
DBs Used: DBF
Location: Alicante - Spain
Contact:

Re: HMG Create object

Post by mustafa »

Code: Select all


#include "hmg.ch"

Function Main()

 myCar_make  = " Ford "
 myCar_model = " Mustang"
 myCar_year  = " 1969"

MsgInfo( 'My Car: ' + myCar_make + myCar_model + myCar_year )

Return

Hello Zoltan
Have if you can serve
Mustafa
User avatar
miszler.zoltan
Posts: 22
Joined: Sun May 26, 2013 12:37 pm
Location: Hungary
Contact:

Re: HMG Create object

Post by miszler.zoltan »

Hello Mustafa!
Not variables, or array, but I object to solve ...
User avatar
luisvasquezcl
Posts: 1258
Joined: Thu Jul 31, 2008 3:23 am
Location: Chile
Contact:

Re: HMG Create object

Post by luisvasquezcl »

Hi,
you can do the following:
#include "hbclass.ch"
#include "hmg.ch"

proc main
local Mycar := Car()
myCar:make = " Ford "
myCar:model = " Mustang"
myCar:year = " 1969"

MsgInfo( 'My Car: ' + myCar:make + myCar:model + myCar:year )
return

class car
data make, model, year
end class
i hope it will be helpful
Best regards
Luis Vasquez
User avatar
luisvasquezcl
Posts: 1258
Joined: Thu Jul 31, 2008 3:23 am
Location: Chile
Contact:

Re: HMG Create object

Post by luisvasquezcl »

They can initiate variables with values as follows:
CLASS Car
DATA Make AS CHARACTER INIT ""
DATA Model AS CHARACTER INIT ""
DATA Year AS CHARACTER INIT ""
END CLASS
User avatar
Amarante
Posts: 182
Joined: Fri Apr 27, 2012 9:44 pm
DBs Used: DBF, MySQL, MariaDB, SQLite, PostgreSQL
Location: Araruama-RJ, Brazil

Re: HMG Create object

Post by Amarante »

Hi Zoltan,
There you will find an example I made using objects as well as SQL.
http://hmgforum.com/viewtopic.php?f=37&t=4293#p40736

I hope you find it useful.
Regards
Amarante
User avatar
miszler.zoltan
Posts: 22
Joined: Sun May 26, 2013 12:37 pm
Location: Hungary
Contact:

Re: HMG Create object

Post by miszler.zoltan »

Gentlemen!
Thanks to the joint thinking and answers!
Post Reply