SlideShare a Scribd company logo
Ring Documentation, Release 1.5.1
Output:
1
1
0
41.9 packages() Function
We can get a list of packages names using the packages() function.
Syntax:
packages() --> a list contains packages names
Example:
See packages()
Package Package1
Class class1
Func f1
Package Package2
Class class1
Func f1
Package Package3
Class class1
Func f1
Package Package4
Class class1
Func f1
Output:
package1
package2
package3
package4
41.10 ispackage() Function
We can check if a package is defined or not using the ispackage() function.
Syntax:
ispackage(cPackageName) --> returns 1 if the Package is defined
returns 0 if the Package is not defined
Example:
See ispackage("package1") + nl +
ispackage("package4") + nl +
ispackage("package5") + nl +
ispackage("package3") + nl
41.9. packages() Function 275
Ring Documentation, Release 1.5.1
Package Package1
Class class1
Func f1
Package Package2
Class class1
Func f1
Package Package3
Class class1
Func f1
Package Package4
Class class1
Func f1
Output:
1
1
0
1
41.11 classes() Function
We can get a list of classes names using the classes() function.
Syntax:
classes() --> a list contains classes names
Example:
See classes()
Class class1
Func f1
Class class2
Func f1
Class class3
Func f1
Output:
class1
class2
class3
41.12 isclass() Function
We can check if a class is defined or not using the isclass() function.
Syntax:
41.11. classes() Function 276
Ring Documentation, Release 1.5.1
isclass(cClassName) --> returns 1 if the Class is defined
returns 0 if the Class is not defined
Example:
see isclass("class4") + nl +
isclass("class3") + nl +
isclass("class2") + nl
Class class1
func f1
class class2
func f1
class class3
func f1
Output:
0
1
1
41.13 packageclasses() Function
We can get a list of classes names inside a package using the packageclasses() function.
Syntax:
packageclasses(cPackageName) --> a list contains classes names inside the package
Example:
see "classes in Package1" + nl
see packageclasses("Package1")
see "classes in Package2" + nl
see packageclasses("Package2")
Package Package1
Class class1
Func f1
Package Package2
Class class1
Func f1
Class class2
Func f1
Class class3
func f1
Output:
classes in Package1
class1
classes in Package2
class1
41.13. packageclasses() Function 277
Ring Documentation, Release 1.5.1
class2
class3
41.14 ispackageclass() Function
We can check if a class is defined inside package or not using the ispackageclass() function.
Syntax:
ispackageclass(cPackageName,cClassName) --> returns 1 if the Class is defined
returns 0 if the Class is not defined
Example:
see ispackageclass("package1","class1") + nl +
ispackageclass("package1","class2") + nl +
ispackageclass("package2","class1") + nl +
ispackageclass("package2","class2") + nl
Package Package1
Class class1
Func f1
Package Package2
Class class1
Func f1
Class class2
Func f1
Class class3
func f1
Output:
1
0
1
1
41.15 classname() Function
We can know the class name of an object using the classname() function
Syntax:
classname(object) --> Returns the object class name
Example:
o1 = new point
o2 = new rect
see classname(o1) + nl # print point
see classname(o2) + nl # print rect
class point
class rect
41.14. ispackageclass() Function 278
Ring Documentation, Release 1.5.1
41.16 objectid() Function
We can know the object id using the objectid() function
Syntax:
objectid(object) --> Returns the object id
Example:
o1 = new point
see objectid(o1) + nl
test(o1)
func test v
see objectid(v) + nl
Class point x y z
Output:
021B5808
021B5808
41.17 isobject() Function
We can check the variable to know if it’s an object or not using the isobject() function
Syntax:
isobject(variable) --> Returns True if it's an object, False if it's not
41.18 attributes() Function
We can get the object attributes using the attributes() function
Syntax:
attributes(object) --> Returns a list contains the object attributes
Example:
o1 = new point
aList = attributes(o1) # we can use see attributes(o1)
for t in aList see t next # print xyz
Class Point x y z
41.19 methods() Function
We can get the object methods using the methods() function
Syntax:
41.16. objectid() Function 279
Ring Documentation, Release 1.5.1
methods(object) --> Returns a list contains the object methods
Example:
o1 = new test
aList = methods(o1)
for x in aList
cCode = "o1."+x+"()"
eval(cCode)
next
Class Test
func f1
see "hello from f1" + nl
func f2
see "hello from f2" + nl
func f3
see "hello from f3" + nl
func f4
see "hello from f4" + nl
Output:
hello from f1
hello from f2
hello from f3
hello from f4
41.20 isattribute() Function
We can test if the object contains an attribute or not using the isattribute() function
Syntax:
isattribute(object,cAttributeName) --> Returns True if the object contains the attribute
Example:
o1 = new point
see isattribute(o1,"x") + nl # print 1
see isattribute(o1,"t") + nl # print 0
see isattribute(o1,"y") + nl # print 1
see isattribute(o1,"z") + nl # print 1
class point x y z
41.21 isprivateattribute() Function
We can test if the object contains a private attribute or not using the isprivateattribute() function
Syntax:
41.20. isattribute() Function 280
Ring Documentation, Release 1.5.1
isprivateattribute(object,cAttributeName) --> Returns True if the object
contains the private attribute
Example:
o1 = new person
see isprivateattribute(o1,"name") + nl +
isprivateattribute(o1,"address") + nl +
isprivateattribute(o1,"phone") + nl +
isprivateattribute(o1,"job") + nl +
isprivateattribute(o1,"salary")
Class Person
name address phone
private
job salary
Output:
0
0
0
1
1
41.22 ismethod() Function
We can test if the object class contains a method or not using the ismethod() function
Syntax:
ismethod(object,cMethodName) --> Returns True if the object class contains the method
Example:
o1 = new point
see ismethod(o1,"print") + nl # print 1
mylist = []
mylist + new point
see ismethod(mylist[1],"print") + nl # print 1
class point x y z
func print
see x + nl + y + nl + z + nl
41.23 isprivatemethod() Function
We can test if the object class contains a private method or not using the isprivatemethod() function
Syntax:
41.22. ismethod() Function 281
Ring Documentation, Release 1.5.1
isprivatemethod(object,cMethodName) --> Returns True if the object class contains
the private method
Example:
o1 = new Test
see isprivatemethod(o1,"f1") + nl +
isprivatemethod(o1,"f2")
Class Test
func f1
see "message from f1()" + nl
private
func f2
see "message from f2()" + nl
Output:
0
1
41.24 addattribute() Function
We can add an attribute (or a group of attributes) to the object state (not the class) using the addattribute() function
Syntax:
AddAttribute(object,cAttributeName|aAttributesList)
Example(1):
see new point {x=10 y=20 z=30}
Class Point
AddAttribute(self,["x","y","z"])
Example(2):
o1 = new point
addattribute(o1,"x")
addattribute(o1,"y")
addattribute(o1,"z")
see o1 {x=10 y=20 z=30}
class point
Output:
x: 10.000000
y: 20.000000
z: 30.000000
41.25 addmethod() Function
We can add a method to the object class using the addmethod() function This method can be used with any object from
the same class.
41.24. addattribute() Function 282
Ring Documentation, Release 1.5.1
Syntax:
AddMethod(Object,cNewMethodName,cMethodName|AnonymousFunction)
Example:
o1 = new point { x=10 y=20 z=30 }
addmethod(o1,"print", func { see x + nl + y + nl + z + nl } )
o1.print()
Class point
x y z
Output:
10
20
30
Instead of using anonymous function to add new method to the class, we can use the function name
Example:
o1 = new point { x=10 y=20 z=30 }
myfunc = func { see x + nl + y + nl + z + nl }
addmethod(o1,"print", myfunc )
addmethod(o1,"display", myfunc )
addmethod(o1,"show", myfunc )
o1.print()
o1.display()
o1.show()
Class point
x y z
Output:
10
20
30
10
20
30
10
20
30
Since we add the method to the class, any object from that class can use this method
Example:
o1 = new point { x=10 y=20 z=30 }
o2 = new point { x=100 y=200 z=300 }
o3 = new point { x=50 y=150 z=250 }
addmethod(o1,"print", func { see x + nl + y + nl + z + nl } )
41.25. addmethod() Function 283
Ring Documentation, Release 1.5.1
o1.print()
o2.print()
o3.print()
Class point
x y z
Output:
10
20
30
100
200
300
50
150
250
41.26 getattribute() function
We can get the object attribute value using the getattribute() function
Syntax:
GetAttribute(oObject,cAttributeName) ---> Attribute Value
Example:
o1 = new point
see getattribute(o1,"name") + nl +
getattribute(o1,"x") + nl +
getattribute(o1,"y") + nl +
getattribute(o1,"z") + nl
Class Point
x=10 y=20 z=30
name = "3D-Point"
Output:
3D-Point
10
20
30
Example:
We can Find a Class List Member using GetAttribute() using a function findclass() The Find uses the member name,
rather than the column number
myList =
[new Company {position=3 name="Mahmoud" symbol="MHD"},
new Company {position=2 name="Bert" symbol="BRT"},
new Company {position=1 name="Ring" symbol="RNG"}
]
41.26. getattribute() function 284

More Related Content

PDF
The Ring programming language version 1.8 book - Part 38 of 202
PDF
The Ring programming language version 1.5.2 book - Part 32 of 181
PDF
The Ring programming language version 1.4 book - Part 9 of 30
PDF
The Ring programming language version 1.5 book - Part 6 of 31
PDF
The Ring programming language version 1.5.4 book - Part 33 of 185
PDF
The Ring programming language version 1.3 book - Part 24 of 88
PDF
The Ring programming language version 1.4.1 book - Part 9 of 31
PDF
The Ring programming language version 1.9 book - Part 41 of 210
The Ring programming language version 1.8 book - Part 38 of 202
The Ring programming language version 1.5.2 book - Part 32 of 181
The Ring programming language version 1.4 book - Part 9 of 30
The Ring programming language version 1.5 book - Part 6 of 31
The Ring programming language version 1.5.4 book - Part 33 of 185
The Ring programming language version 1.3 book - Part 24 of 88
The Ring programming language version 1.4.1 book - Part 9 of 31
The Ring programming language version 1.9 book - Part 41 of 210

What's hot (20)

PDF
The Ring programming language version 1.2 book - Part 22 of 84
PDF
The Ring programming language version 1.7 book - Part 36 of 196
PDF
The Ring programming language version 1.6 book - Part 35 of 189
PDF
The Ring programming language version 1.10 book - Part 42 of 212
PDF
The Ring programming language version 1.5.3 book - Part 33 of 184
PDF
The Ring programming language version 1.7 book - Part 34 of 196
PDF
The Ring programming language version 1.5.1 book - Part 29 of 180
PDF
The Ring programming language version 1.5.1 book - Part 30 of 180
PDF
The Ring programming language version 1.5.4 book - Part 31 of 185
PDF
The Ring programming language version 1.5.2 book - Part 31 of 181
PDF
The Ring programming language version 1.10 book - Part 40 of 212
PDF
The Ring programming language version 1.5.3 book - Part 31 of 184
PDF
The Ring programming language version 1.6 book - Part 32 of 189
PDF
The Ring programming language version 1.6 book - Part 34 of 189
PDF
The Ring programming language version 1.3 book - Part 22 of 88
PDF
The Ring programming language version 1.2 book - Part 21 of 84
PDF
The Ring programming language version 1.3 book - Part 23 of 88
PDF
The Ring programming language version 1.6 book - Part 40 of 189
PDF
The Ring programming language version 1.5.4 book - Part 32 of 185
PDF
The Ring programming language version 1.9 book - Part 39 of 210
The Ring programming language version 1.2 book - Part 22 of 84
The Ring programming language version 1.7 book - Part 36 of 196
The Ring programming language version 1.6 book - Part 35 of 189
The Ring programming language version 1.10 book - Part 42 of 212
The Ring programming language version 1.5.3 book - Part 33 of 184
The Ring programming language version 1.7 book - Part 34 of 196
The Ring programming language version 1.5.1 book - Part 29 of 180
The Ring programming language version 1.5.1 book - Part 30 of 180
The Ring programming language version 1.5.4 book - Part 31 of 185
The Ring programming language version 1.5.2 book - Part 31 of 181
The Ring programming language version 1.10 book - Part 40 of 212
The Ring programming language version 1.5.3 book - Part 31 of 184
The Ring programming language version 1.6 book - Part 32 of 189
The Ring programming language version 1.6 book - Part 34 of 189
The Ring programming language version 1.3 book - Part 22 of 88
The Ring programming language version 1.2 book - Part 21 of 84
The Ring programming language version 1.3 book - Part 23 of 88
The Ring programming language version 1.6 book - Part 40 of 189
The Ring programming language version 1.5.4 book - Part 32 of 185
The Ring programming language version 1.9 book - Part 39 of 210
Ad

Similar to The Ring programming language version 1.5.1 book - Part 31 of 180 (12)

PDF
The Ring programming language version 1.5.3 book - Part 32 of 184
PDF
The Ring programming language version 1.10 book - Part 43 of 212
PDF
The Ring programming language version 1.7 book - Part 37 of 196
PDF
The Ring programming language version 1.6 book - Part 33 of 189
PDF
The Ring programming language version 1.5.2 book - Part 30 of 181
PDF
The Ring programming language version 1.5.1 book - Part 32 of 180
PDF
The Ring programming language version 1.2 book - Part 20 of 84
PDF
The Ring programming language version 1.5.2 book - Part 37 of 181
PDF
The Ring programming language version 1.5.1 book - Part 36 of 180
PDF
The Ring programming language version 1.5.3 book - Part 30 of 184
PDF
The Ring programming language version 1.8 book - Part 36 of 202
PDF
The Ring programming language version 1.9 book - Part 40 of 210
The Ring programming language version 1.5.3 book - Part 32 of 184
The Ring programming language version 1.10 book - Part 43 of 212
The Ring programming language version 1.7 book - Part 37 of 196
The Ring programming language version 1.6 book - Part 33 of 189
The Ring programming language version 1.5.2 book - Part 30 of 181
The Ring programming language version 1.5.1 book - Part 32 of 180
The Ring programming language version 1.2 book - Part 20 of 84
The Ring programming language version 1.5.2 book - Part 37 of 181
The Ring programming language version 1.5.1 book - Part 36 of 180
The Ring programming language version 1.5.3 book - Part 30 of 184
The Ring programming language version 1.8 book - Part 36 of 202
The Ring programming language version 1.9 book - Part 40 of 210
Ad

More from Mahmoud Samir Fayed (20)

PDF
The Ring programming language version 1.10 book - Part 212 of 212
PDF
The Ring programming language version 1.10 book - Part 211 of 212
PDF
The Ring programming language version 1.10 book - Part 210 of 212
PDF
The Ring programming language version 1.10 book - Part 208 of 212
PDF
The Ring programming language version 1.10 book - Part 207 of 212
PDF
The Ring programming language version 1.10 book - Part 205 of 212
PDF
The Ring programming language version 1.10 book - Part 206 of 212
PDF
The Ring programming language version 1.10 book - Part 204 of 212
PDF
The Ring programming language version 1.10 book - Part 203 of 212
PDF
The Ring programming language version 1.10 book - Part 202 of 212
PDF
The Ring programming language version 1.10 book - Part 201 of 212
PDF
The Ring programming language version 1.10 book - Part 200 of 212
PDF
The Ring programming language version 1.10 book - Part 199 of 212
PDF
The Ring programming language version 1.10 book - Part 198 of 212
PDF
The Ring programming language version 1.10 book - Part 197 of 212
PDF
The Ring programming language version 1.10 book - Part 196 of 212
PDF
The Ring programming language version 1.10 book - Part 195 of 212
PDF
The Ring programming language version 1.10 book - Part 194 of 212
PDF
The Ring programming language version 1.10 book - Part 193 of 212
PDF
The Ring programming language version 1.10 book - Part 192 of 212
The Ring programming language version 1.10 book - Part 212 of 212
The Ring programming language version 1.10 book - Part 211 of 212
The Ring programming language version 1.10 book - Part 210 of 212
The Ring programming language version 1.10 book - Part 208 of 212
The Ring programming language version 1.10 book - Part 207 of 212
The Ring programming language version 1.10 book - Part 205 of 212
The Ring programming language version 1.10 book - Part 206 of 212
The Ring programming language version 1.10 book - Part 204 of 212
The Ring programming language version 1.10 book - Part 203 of 212
The Ring programming language version 1.10 book - Part 202 of 212
The Ring programming language version 1.10 book - Part 201 of 212
The Ring programming language version 1.10 book - Part 200 of 212
The Ring programming language version 1.10 book - Part 199 of 212
The Ring programming language version 1.10 book - Part 198 of 212
The Ring programming language version 1.10 book - Part 197 of 212
The Ring programming language version 1.10 book - Part 196 of 212
The Ring programming language version 1.10 book - Part 195 of 212
The Ring programming language version 1.10 book - Part 194 of 212
The Ring programming language version 1.10 book - Part 193 of 212
The Ring programming language version 1.10 book - Part 192 of 212

Recently uploaded (20)

PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPT
Teaching material agriculture food technology
PPTX
TLE Review Electricity (Electricity).pptx
PPTX
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
Programs and apps: productivity, graphics, security and other tools
PPTX
Machine Learning_overview_presentation.pptx
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Getting Started with Data Integration: FME Form 101
PPTX
Spectroscopy.pptx food analysis technology
PPTX
cloud_computing_Infrastucture_as_cloud_p
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Teaching material agriculture food technology
TLE Review Electricity (Electricity).pptx
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
A comparative analysis of optical character recognition models for extracting...
Accuracy of neural networks in brain wave diagnosis of schizophrenia
MIND Revenue Release Quarter 2 2025 Press Release
Spectral efficient network and resource selection model in 5G networks
Programs and apps: productivity, graphics, security and other tools
Machine Learning_overview_presentation.pptx
Network Security Unit 5.pdf for BCA BBA.
gpt5_lecture_notes_comprehensive_20250812015547.pdf
NewMind AI Weekly Chronicles - August'25-Week II
Diabetes mellitus diagnosis method based random forest with bat algorithm
Assigned Numbers - 2025 - Bluetooth® Document
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Getting Started with Data Integration: FME Form 101
Spectroscopy.pptx food analysis technology
cloud_computing_Infrastucture_as_cloud_p

The Ring programming language version 1.5.1 book - Part 31 of 180

  • 1. Ring Documentation, Release 1.5.1 Output: 1 1 0 41.9 packages() Function We can get a list of packages names using the packages() function. Syntax: packages() --> a list contains packages names Example: See packages() Package Package1 Class class1 Func f1 Package Package2 Class class1 Func f1 Package Package3 Class class1 Func f1 Package Package4 Class class1 Func f1 Output: package1 package2 package3 package4 41.10 ispackage() Function We can check if a package is defined or not using the ispackage() function. Syntax: ispackage(cPackageName) --> returns 1 if the Package is defined returns 0 if the Package is not defined Example: See ispackage("package1") + nl + ispackage("package4") + nl + ispackage("package5") + nl + ispackage("package3") + nl 41.9. packages() Function 275
  • 2. Ring Documentation, Release 1.5.1 Package Package1 Class class1 Func f1 Package Package2 Class class1 Func f1 Package Package3 Class class1 Func f1 Package Package4 Class class1 Func f1 Output: 1 1 0 1 41.11 classes() Function We can get a list of classes names using the classes() function. Syntax: classes() --> a list contains classes names Example: See classes() Class class1 Func f1 Class class2 Func f1 Class class3 Func f1 Output: class1 class2 class3 41.12 isclass() Function We can check if a class is defined or not using the isclass() function. Syntax: 41.11. classes() Function 276
  • 3. Ring Documentation, Release 1.5.1 isclass(cClassName) --> returns 1 if the Class is defined returns 0 if the Class is not defined Example: see isclass("class4") + nl + isclass("class3") + nl + isclass("class2") + nl Class class1 func f1 class class2 func f1 class class3 func f1 Output: 0 1 1 41.13 packageclasses() Function We can get a list of classes names inside a package using the packageclasses() function. Syntax: packageclasses(cPackageName) --> a list contains classes names inside the package Example: see "classes in Package1" + nl see packageclasses("Package1") see "classes in Package2" + nl see packageclasses("Package2") Package Package1 Class class1 Func f1 Package Package2 Class class1 Func f1 Class class2 Func f1 Class class3 func f1 Output: classes in Package1 class1 classes in Package2 class1 41.13. packageclasses() Function 277
  • 4. Ring Documentation, Release 1.5.1 class2 class3 41.14 ispackageclass() Function We can check if a class is defined inside package or not using the ispackageclass() function. Syntax: ispackageclass(cPackageName,cClassName) --> returns 1 if the Class is defined returns 0 if the Class is not defined Example: see ispackageclass("package1","class1") + nl + ispackageclass("package1","class2") + nl + ispackageclass("package2","class1") + nl + ispackageclass("package2","class2") + nl Package Package1 Class class1 Func f1 Package Package2 Class class1 Func f1 Class class2 Func f1 Class class3 func f1 Output: 1 0 1 1 41.15 classname() Function We can know the class name of an object using the classname() function Syntax: classname(object) --> Returns the object class name Example: o1 = new point o2 = new rect see classname(o1) + nl # print point see classname(o2) + nl # print rect class point class rect 41.14. ispackageclass() Function 278
  • 5. Ring Documentation, Release 1.5.1 41.16 objectid() Function We can know the object id using the objectid() function Syntax: objectid(object) --> Returns the object id Example: o1 = new point see objectid(o1) + nl test(o1) func test v see objectid(v) + nl Class point x y z Output: 021B5808 021B5808 41.17 isobject() Function We can check the variable to know if it’s an object or not using the isobject() function Syntax: isobject(variable) --> Returns True if it's an object, False if it's not 41.18 attributes() Function We can get the object attributes using the attributes() function Syntax: attributes(object) --> Returns a list contains the object attributes Example: o1 = new point aList = attributes(o1) # we can use see attributes(o1) for t in aList see t next # print xyz Class Point x y z 41.19 methods() Function We can get the object methods using the methods() function Syntax: 41.16. objectid() Function 279
  • 6. Ring Documentation, Release 1.5.1 methods(object) --> Returns a list contains the object methods Example: o1 = new test aList = methods(o1) for x in aList cCode = "o1."+x+"()" eval(cCode) next Class Test func f1 see "hello from f1" + nl func f2 see "hello from f2" + nl func f3 see "hello from f3" + nl func f4 see "hello from f4" + nl Output: hello from f1 hello from f2 hello from f3 hello from f4 41.20 isattribute() Function We can test if the object contains an attribute or not using the isattribute() function Syntax: isattribute(object,cAttributeName) --> Returns True if the object contains the attribute Example: o1 = new point see isattribute(o1,"x") + nl # print 1 see isattribute(o1,"t") + nl # print 0 see isattribute(o1,"y") + nl # print 1 see isattribute(o1,"z") + nl # print 1 class point x y z 41.21 isprivateattribute() Function We can test if the object contains a private attribute or not using the isprivateattribute() function Syntax: 41.20. isattribute() Function 280
  • 7. Ring Documentation, Release 1.5.1 isprivateattribute(object,cAttributeName) --> Returns True if the object contains the private attribute Example: o1 = new person see isprivateattribute(o1,"name") + nl + isprivateattribute(o1,"address") + nl + isprivateattribute(o1,"phone") + nl + isprivateattribute(o1,"job") + nl + isprivateattribute(o1,"salary") Class Person name address phone private job salary Output: 0 0 0 1 1 41.22 ismethod() Function We can test if the object class contains a method or not using the ismethod() function Syntax: ismethod(object,cMethodName) --> Returns True if the object class contains the method Example: o1 = new point see ismethod(o1,"print") + nl # print 1 mylist = [] mylist + new point see ismethod(mylist[1],"print") + nl # print 1 class point x y z func print see x + nl + y + nl + z + nl 41.23 isprivatemethod() Function We can test if the object class contains a private method or not using the isprivatemethod() function Syntax: 41.22. ismethod() Function 281
  • 8. Ring Documentation, Release 1.5.1 isprivatemethod(object,cMethodName) --> Returns True if the object class contains the private method Example: o1 = new Test see isprivatemethod(o1,"f1") + nl + isprivatemethod(o1,"f2") Class Test func f1 see "message from f1()" + nl private func f2 see "message from f2()" + nl Output: 0 1 41.24 addattribute() Function We can add an attribute (or a group of attributes) to the object state (not the class) using the addattribute() function Syntax: AddAttribute(object,cAttributeName|aAttributesList) Example(1): see new point {x=10 y=20 z=30} Class Point AddAttribute(self,["x","y","z"]) Example(2): o1 = new point addattribute(o1,"x") addattribute(o1,"y") addattribute(o1,"z") see o1 {x=10 y=20 z=30} class point Output: x: 10.000000 y: 20.000000 z: 30.000000 41.25 addmethod() Function We can add a method to the object class using the addmethod() function This method can be used with any object from the same class. 41.24. addattribute() Function 282
  • 9. Ring Documentation, Release 1.5.1 Syntax: AddMethod(Object,cNewMethodName,cMethodName|AnonymousFunction) Example: o1 = new point { x=10 y=20 z=30 } addmethod(o1,"print", func { see x + nl + y + nl + z + nl } ) o1.print() Class point x y z Output: 10 20 30 Instead of using anonymous function to add new method to the class, we can use the function name Example: o1 = new point { x=10 y=20 z=30 } myfunc = func { see x + nl + y + nl + z + nl } addmethod(o1,"print", myfunc ) addmethod(o1,"display", myfunc ) addmethod(o1,"show", myfunc ) o1.print() o1.display() o1.show() Class point x y z Output: 10 20 30 10 20 30 10 20 30 Since we add the method to the class, any object from that class can use this method Example: o1 = new point { x=10 y=20 z=30 } o2 = new point { x=100 y=200 z=300 } o3 = new point { x=50 y=150 z=250 } addmethod(o1,"print", func { see x + nl + y + nl + z + nl } ) 41.25. addmethod() Function 283
  • 10. Ring Documentation, Release 1.5.1 o1.print() o2.print() o3.print() Class point x y z Output: 10 20 30 100 200 300 50 150 250 41.26 getattribute() function We can get the object attribute value using the getattribute() function Syntax: GetAttribute(oObject,cAttributeName) ---> Attribute Value Example: o1 = new point see getattribute(o1,"name") + nl + getattribute(o1,"x") + nl + getattribute(o1,"y") + nl + getattribute(o1,"z") + nl Class Point x=10 y=20 z=30 name = "3D-Point" Output: 3D-Point 10 20 30 Example: We can Find a Class List Member using GetAttribute() using a function findclass() The Find uses the member name, rather than the column number myList = [new Company {position=3 name="Mahmoud" symbol="MHD"}, new Company {position=2 name="Bert" symbol="BRT"}, new Company {position=1 name="Ring" symbol="RNG"} ] 41.26. getattribute() function 284