HMG Create object

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

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

HMG Create object

Post by miszler.zoltan » Thu Oct 22, 2015 12:35 pm

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: 829
Joined: Fri Mar 20, 2009 11:38 am
DBs Used: DBF
Location: Alicante - Spain
Been thanked: 117 times
Contact:

Post by mustafa » Thu Oct 22, 2015 3:55 pm

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: 18
Joined: Sun May 26, 2013 12:37 pm
Location: Hungary
Contact:

Post by miszler.zoltan » Thu Oct 22, 2015 4:58 pm

Hello Mustafa!
Not variables, or array, but I object to solve ...

User avatar
luisvasquezcl
Posts: 1140
Joined: Thu Jul 31, 2008 3:23 am
Location: Chile
Has thanked: 14 times
Been thanked: 14 times
Contact:

Post by luisvasquezcl » Thu Oct 22, 2015 5:53 pm

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: 1140
Joined: Thu Jul 31, 2008 3:23 am
Location: Chile
Has thanked: 14 times
Been thanked: 14 times
Contact:

Post by luisvasquezcl » Thu Oct 22, 2015 5:59 pm

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
Location: Araruama-RJ, Brazil

Post by Amarante » Thu Oct 22, 2015 8:07 pm

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: 18
Joined: Sun May 26, 2013 12:37 pm
Location: Hungary
Contact:

Post by miszler.zoltan » Fri Nov 06, 2015 7:51 am

Gentlemen!
Thanks to the joint thinking and answers!

Post Reply