HSPの配列でモジュール変数再現Lite

  • タグ:
  • hsp
#module Person
	#enum name=0
	#enum age
	#enum high
	#define ctype new(%1,%2,%3,%4) \
		sdim %1,,3:__new@Person %1,%2,%3,%4
	#deffunc local __new array this,str _name,int _age,double _high
		this.name=_name
		this.age=str(_age)
		this.high=str(_high)
	return

	#defcfunc psName array this
		return this.name

	#defcfunc psAge array this
		return int(this.age)

	#defcfunc psHigh array this
		return double(this.high)
#global

new@Person(bob,"bob",20,170.5)
new@Person(kate,"kate",17,155.2)
mes strf("name:%s age:%d high:%.1fcm",psName(bob),psAge(bob),psHigh(bob))
mes strf("name:%s age:%d high:%.1fcm",psName(kate),psAge(kate),psHigh(kate))