The following examples need the latest Oxygen compile download, (relaxing some requirements for empty brackets)
[code=thinbasic]
'CLASSES AND METHODS
'
uses "oxygen","file"
dim p0,p1 as long, src as string
dim dd(100) as double
src = "
class stat
method sum() as double
method average() as double
/
da(100) as double
dn as long
end class
'--------------
methods of stat
'==============
method sum() as double
dim i
for i = 1 to this.dn
method += this.da(i)
next
end method
method average() as double
method = this.sum / this.dn
end method
end methods
'====
'TEST
'====
dim s as stat
s.da=>2,4,6,8,10,12,14,16,18
s.dn=9
print `Sum: ` str(s.sum) ` Average: ` str s.average
"
o2_basic src
'msgbox 0, o2_view "o2h "+src
if len(o2_error) then
msgbox 0, o2_error : stop
end if
o2_exec
[/code]
Bookmarks