#pragma rtGlobals=1 // Use modern global access method. function FILE_OOP_example() end function CLASS_person____() // write class description here: (it will automatically be used by docMaker class) end function person_init() // init funciton for person class: initialize members & gui parameters // define members string /g name = "Jack" string /g dateofbirth = "1990/1/1" // call gui init function person_guiParam() end function person_guiParam() // initialize GUI parameter for shape class // guiparam_edit: wave that keeps information of the gui panel make /o/t/n=0 guiparam_edit // util_appendToTWave(targetWave, contents) append "contents" to targetWave util_appendToTWave("guiparam_edit", "str;name;") util_appendToTWave("guiparam_edit", "str;dateofbirth;") util_appendToTWave("guiparam_edit", "btn;printage;") util_appendToTWave("guiparam_edit", "btn;sayhello;") end function person_printage() // calculate current age and print it in the command window SVAR dateofbirth // access dateofbirth data member if (itemsinlist(dateofbirth,"/") != 3) print "Wrong date format! Date should be YYYY/MM/DD" return -1 endif variable year =str2num(stringfromlist(0,dateofbirth,"/")) variable month = str2num(stringfromlist(1,dateofbirth,"/")) variable day = str2num(stringfromlist(2,dateofbirth,"/")) variable sec = date2secs(year,month,day) variable now = datetime variable age = floor((now-sec)/(60*60*24*365.25)) SVAR name string str sprintf str "%s is %d years old.", name, age print str end function person_sayhello() // no practical use at all SVAR name string str sprintf str, "Hello, my name is %s. How are you doing?", name print str end function german_init() obj_inherit("person") end function german_sayhello() SVAR name string str sprintf str, "Hallo, mein Name ist %s. Wie geht es Ihnen?", name print str end