Call an object method: Difference between revisions

Content added Content deleted
No edit summary
Line 1,027: Line 1,027:
print(b:tellSecret())
print(b:tellSecret())
print(box.count())</lang>
print(box.count())</lang>

=={{header|M2000 Interpreter}}==
In M2000 there are some kinds of objects. Group is the one type object. We can compose members to groups, with functions, operators, modules, events, and inner groups, among other members of type pointer to object. Another type is the COM type. Here we see the Group object
<lang M2000 Interpreter>
Module CheckIt {
\\ A class definition is a function which return a Group
\\ We can make groups and we can alter them using Group statement
\\ Groups may have other groups inside
Group Alfa {
Private:
myvalue=100
Public:
Group SetValue {
Set (x) {
Link parent myvalue to m
m<=x
}
}
Module MyMethod {
Read x
Print x*.myvalue
}
}
Alfa.MyMethod 5 '500
Alfa.MyMethod %x=200 ' 20000
\\ we can copy Alfa to Z
Z=Alfa
Z.MyMethod 5
Z.SetValue=300
Z.MyMethod 5 ' 1500
Alfa.MyMethod 5 ' 500
Dim A(10)
A(3)=Z
A(3).MyMethod 5 '1500
A(3).SetValue=200
A(3).MyMethod 5 '1000
\\ get a pointer of group in A(3)
k->A(3)
k=>SetValue=100
A(3).MyMethod 5 '500
\\ k get pointer to Alfa
k->Alfa
k=>SetValue=500
Alfa.MyMethod 5 '2500
k->Z
k=>MyMethod 5 ' 1500
Z.SetValue=100
k=>MyMethod 5 ' 500
}
Checkit
</lang>




=={{header|Maple}}==
=={{header|Maple}}==