SlideShare a Scribd company logo
Ring Documentation, Release 1.7
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 } )
o1.print()
o2.print()
o3.print()
Class point
x y z
Output:
10
20
30
100
200
300
43.25. addmethod() Function 332
Ring Documentation, Release 1.7
50
150
250
43.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"}
]
see myList
see nl +"=====================" + nl + nl
for i = 1 to len(myList)
see "Pos: "+ i +" | "+ myList[i].position +" | "+ myList[i].name +
" | "+ myList[i].symbol +" | "+ nl
next
See findclass(myList, "MHD", "symbol") +nl ### Specify Member class name
###---------------------------------------
func findclass classList, cValue, classMember
43.26. getattribute() function 333
Ring Documentation, Release 1.7
See nl + "FindClass: " +" "+ cValue + nl + nl
for i = 1 to len(classList)
result = getattribute( classList[i], classMember )
See "Result-Attr: " + i +" "+ result +nl
if result = cValue
j = i
ok
next
return j
###--------------------------------------
class company position name symbol
Output:
Pos: 1 | 3 | Mahmoud | MHD |
Pos: 2 | 2 | Bert | BRT |
Pos: 3 | 1 | Ring | RNG |
FindClass: MHD
Result-Attr: 1 MHD
Result-Attr: 2 BRT
Result-Attr: 3 RNG
1
43.27 setattribute() function
We can set the object attribute value using the setattribute() function
Syntax:
SetAttribute(oObject,cAttributeName,Value)
Example:
o1 = new person
setattribute(o1,"cName","Mahmoud")
setattribute(o1,"nSalary",1000000)
setattribute(o1,"aColors",["white","blue","yellow"])
see o1
see o1.aColors
Class Person
cName
nSalary
aColors
Output:
cname: Mahmoud
nsalary: 1000000.000000
43.27. setattribute() function 334
Ring Documentation, Release 1.7
acolors: List...
white
blue
yellow
43.28 mergemethods() Function
We can share methods between classes without inheritance using the MergeMethods() function
This function merge class methods to another class.
Syntax:
MergeMethods(cClassNameDestination,cClassNameSource)
Example:
mergemethods("count","share")
mergemethods("count2","share")
o1 = new count { test() }
o1 = new count2 { test() }
Class Share
func one
see "one" + nl
func two
see "two" + nl
func three
see "three" + nl
Class Display
Func printline
see copy("*",20) + nl
Class Count from Display
Func test
printline()
one()
two()
three()
printline()
Class Count2 from Display
Func test
three()
two()
one()
printline()
Output:
********************
one
two
three
********************
43.28. mergemethods() Function 335
Ring Documentation, Release 1.7
three
two
one
********************
43.29 packagename() Function
We can know the package name of the latest sucessful import command using the packagename() function
Syntax:
packagename() --> Returns the package name of the latest sucessful import
Example:
load "weblib.ring"
import System.web
see packagename() # system.web
43.29. packagename() Function 336
CHAPTER
FORTYFOUR
STDLIB FUNCTIONS
In this chapter we are going to learn about functions in the stdlib.ring
Before using the functions in the library, We must load the library first
load "stdlib.ring"
Instead of using stdlib.ring we can use stdlibcore.ring
Using stdlibcore.ring we can use the StdLib functions (Without Classes)
This is useful when developing standalone console applications
Because using stdlib.ring (functions & classes) will load libraries like RingLibCurl, RingOpenSSL, etc.
44.1 Puts() function
print the value then print new line (nl)
Syntax:
puts(expr)
Example:
Load "stdlib.ring"
Puts("Hello, World!")
44.2 Print() function
print string - support n,t and r
Also we can use #{variable_name} to insert variables values.
Syntax:
print(string) ---> String
Example:
print("nHello, WorldnnHow are you? tt I'm fine!n")
x=10 y=20
print("nx value = #{x} , y value = #{y} n")
337
Ring Documentation, Release 1.7
44.3 Print2Str() Function
Syntax:
print2Str(string) ---> String
Example:
world = "World!"
mystring = print2str("Hello, #{world} nIn Year n#{2000+17} n")
see mystring + nl
Output:
Hello, World!
In Year
2017
44.4 GetString() function
Get input from the keyboard - return value as string
getstring() ---> string
44.5 GetNumber() function
Get input from the keyboard - return value as number
getnumber() ---> number
44.6 AppPath() function
Get the path of the application folder
Syntax:
AppPath() ---> The path as String
Example:
Load "stdlib.ring"
# Application Path
Puts("Test AppPath()")
See AppPath() + nl
44.7 JustFilePath() function
Get the path of the file, remove the file name.
44.3. Print2Str() Function 338
Ring Documentation, Release 1.7
Syntax:
JustFilePath(cFile) ---> The path as String
Example:
load "stdlib.ring"
see justfilePath("b:ringapplicationsrnoternote.ring")
Output:
b:ringapplicationsrnote
44.8 JustFileName() function
Get the file, remove the file path.
Syntax:
JustFileName(cFile) ---> The file name as String
Example:
load "stdlib.ring"
see justfileName("b:ringapplicationsrnoternote.ring")
Output:
rnote.ring
44.9 Value() function
create a copy from a list or object
Syntax:
value(List) ---> new list
Example:
Load "stdlib.ring"
aList = 1:10
del(value(aList),1) # delete first item
see aList # print numbers from 1 to 10
44.10 Times() function
Execute a Function nCount times
Syntax:
44.8. JustFileName() function 339
Ring Documentation, Release 1.7
Times(nCount,function)
Example:
Load "stdlib.ring"
Puts("Test Times()")
Times ( 3 , func { see "Hello, World!" + nl } )
44.11 Map() function
Execute a Function on each list item
Syntax:
Map(alist,function) ---> List
Example:
Load "stdlib.ring"
Puts("Test Map()")
See Map( 1:10, func x { return x*x } )
44.12 Filter() function
Execute a Function on each list item to filter items
Syntax:
Filter(alist,function) ---> List
Example:
Load "stdlib.ring"
Puts("Test Filter()")
See Filter( 1:10 , func x { if x <= 5 return true else return false ok } )
44.13 Split() function
Convert string words to list items
Syntax:
Split(cstring,delimiter) ---> List
Example:
Load "stdlib.ring"
Puts("Test Split()")
See Split("one two three four five"," ")
44.11. Map() function 340
Ring Documentation, Release 1.7
44.14 SplitMany() function
Convert string words to list items. Allow many delimiters.
Syntax:
SplitMany(cstring,delimiters as string or list) --> List
Example:
Load "stdlib.ring"
Puts("Test SplitMany()")
See SplitMany("one,two,three,four and five"," ,")
44.15 NewList() function
Create a two dimensional list
Syntax:
NewList(nRows,nColumns) ---> new list
Example:
Load "stdlib.ring"
Puts("Test Newlist()")
a1 = 3
a2 = 5
chrArray = newlist(a1,a2)
numArray = newlist(a1,a2)
chrArray[1][1] = "Hello"
numArray[1][1] = 987.2
See chrArray[1][1] + nl
See numArray[1][1] + nl
44.16 Capitalized() function
Return a copy of a string with the first letter capitalized
Syntax:
Capitalized(string) ---> string
Example:
Load "stdlib.ring"
Puts("Test Capitalized()")
See capitalized("welcome to the Ring Programming Language")
44.14. SplitMany() function 341

More Related Content

PDF
The Ring programming language version 1.10 book - Part 43 of 212
PDF
The Ring programming language version 1.6 book - Part 35 of 189
PDF
The Ring programming language version 1.5.2 book - Part 33 of 181
PDF
The Ring programming language version 1.5.4 book - Part 33 of 185
PDF
The Ring programming language version 1.8 book - Part 39 of 202
PDF
The Ring programming language version 1.7 book - Part 34 of 196
PDF
The Ring programming language version 1.6 book - Part 36 of 189
PDF
The Ring programming language version 1.3 book - Part 24 of 88
The Ring programming language version 1.10 book - Part 43 of 212
The Ring programming language version 1.6 book - Part 35 of 189
The Ring programming language version 1.5.2 book - Part 33 of 181
The Ring programming language version 1.5.4 book - Part 33 of 185
The Ring programming language version 1.8 book - Part 39 of 202
The Ring programming language version 1.7 book - Part 34 of 196
The Ring programming language version 1.6 book - Part 36 of 189
The Ring programming language version 1.3 book - Part 24 of 88

What's hot (20)

PDF
The Ring programming language version 1.9 book - Part 41 of 210
PDF
The Ring programming language version 1.2 book - Part 23 of 84
PDF
The Ring programming language version 1.9 book - Part 42 of 210
PDF
The Ring programming language version 1.5.3 book - Part 33 of 184
PDF
The Ring programming language version 1.5.2 book - Part 32 of 181
PDF
The Ring programming language version 1.3 book - Part 83 of 88
PDF
The Ring programming language version 1.5.1 book - Part 29 of 180
PDF
The Ring programming language version 1.4 book - Part 9 of 30
PDF
The Ring programming language version 1.2 book - Part 22 of 84
PDF
The Ring programming language version 1.6 book - Part 32 of 189
PDF
The Ring programming language version 1.5.3 book - Part 30 of 184
PDF
The Ring programming language version 1.5.1 book - Part 31 of 180
PDF
The Ring programming language version 1.3 book - Part 22 of 88
PDF
The Ring programming language version 1.5.4 book - Part 31 of 185
PDF
The Ring programming language version 1.2 book - Part 24 of 84
PDF
The Ring programming language version 1.8 book - Part 38 of 202
PDF
The Ring programming language version 1.6 book - Part 183 of 189
PDF
The Ring programming language version 1.5.1 book - Part 36 of 180
PDF
The Ring programming language version 1.3 book - Part 25 of 88
PDF
The Ring programming language version 1.9 book - Part 38 of 210
The Ring programming language version 1.9 book - Part 41 of 210
The Ring programming language version 1.2 book - Part 23 of 84
The Ring programming language version 1.9 book - Part 42 of 210
The Ring programming language version 1.5.3 book - Part 33 of 184
The Ring programming language version 1.5.2 book - Part 32 of 181
The Ring programming language version 1.3 book - Part 83 of 88
The Ring programming language version 1.5.1 book - Part 29 of 180
The Ring programming language version 1.4 book - Part 9 of 30
The Ring programming language version 1.2 book - Part 22 of 84
The Ring programming language version 1.6 book - Part 32 of 189
The Ring programming language version 1.5.3 book - Part 30 of 184
The Ring programming language version 1.5.1 book - Part 31 of 180
The Ring programming language version 1.3 book - Part 22 of 88
The Ring programming language version 1.5.4 book - Part 31 of 185
The Ring programming language version 1.2 book - Part 24 of 84
The Ring programming language version 1.8 book - Part 38 of 202
The Ring programming language version 1.6 book - Part 183 of 189
The Ring programming language version 1.5.1 book - Part 36 of 180
The Ring programming language version 1.3 book - Part 25 of 88
The Ring programming language version 1.9 book - Part 38 of 210
Ad

Similar to The Ring programming language version 1.7 book - Part 37 of 196 (16)

PDF
The Ring programming language version 1.5.1 book - Part 32 of 180
PDF
The Ring programming language version 1.10 book - Part 40 of 212
PDF
The Ring programming language version 1.6 book - Part 33 of 189
PDF
The Ring programming language version 1.5.3 book - Part 31 of 184
PDF
The Ring programming language version 1.5 book - Part 6 of 31
PDF
The Ring programming language version 1.2 book - Part 20 of 84
PDF
The Ring programming language version 1.5.2 book - Part 30 of 181
PDF
The Ring programming language version 1.9 book - Part 39 of 210
PDF
The Ring programming language version 1.7 book - Part 35 of 196
PDF
The Ring programming language version 1.8 book - Part 36 of 202
PDF
The Ring programming language version 1.4.1 book - Part 9 of 31
PDF
The Ring programming language version 1.5.4 book - Part 34 of 185
PDF
The Ring programming language version 1.10 book - Part 42 of 212
PDF
The Ring programming language version 1.7 book - Part 36 of 196
PDF
The Ring programming language version 1.4.1 book - Part 29 of 31
PDF
The Ring programming language version 1.5.3 book - Part 34 of 184
The Ring programming language version 1.5.1 book - Part 32 of 180
The Ring programming language version 1.10 book - Part 40 of 212
The Ring programming language version 1.6 book - Part 33 of 189
The Ring programming language version 1.5.3 book - Part 31 of 184
The Ring programming language version 1.5 book - Part 6 of 31
The Ring programming language version 1.2 book - Part 20 of 84
The Ring programming language version 1.5.2 book - Part 30 of 181
The Ring programming language version 1.9 book - Part 39 of 210
The Ring programming language version 1.7 book - Part 35 of 196
The Ring programming language version 1.8 book - Part 36 of 202
The Ring programming language version 1.4.1 book - Part 9 of 31
The Ring programming language version 1.5.4 book - Part 34 of 185
The Ring programming language version 1.10 book - Part 42 of 212
The Ring programming language version 1.7 book - Part 36 of 196
The Ring programming language version 1.4.1 book - Part 29 of 31
The Ring programming language version 1.5.3 book - Part 34 of 184
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
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Machine learning based COVID-19 study performance prediction
PPT
Teaching material agriculture food technology
PDF
KodekX | Application Modernization Development
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Spectral efficient network and resource selection model in 5G networks
DOCX
The AUB Centre for AI in Media Proposal.docx
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Empathic Computing: Creating Shared Understanding
PPTX
Spectroscopy.pptx food analysis technology
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
Programs and apps: productivity, graphics, security and other tools
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
MIND Revenue Release Quarter 2 2025 Press Release
Advanced methodologies resolving dimensionality complications for autism neur...
Digital-Transformation-Roadmap-for-Companies.pptx
Encapsulation_ Review paper, used for researhc scholars
20250228 LYD VKU AI Blended-Learning.pptx
Machine learning based COVID-19 study performance prediction
Teaching material agriculture food technology
KodekX | Application Modernization Development
Diabetes mellitus diagnosis method based random forest with bat algorithm
Review of recent advances in non-invasive hemoglobin estimation
Understanding_Digital_Forensics_Presentation.pptx
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Spectral efficient network and resource selection model in 5G networks
The AUB Centre for AI in Media Proposal.docx
“AI and Expert System Decision Support & Business Intelligence Systems”
Empathic Computing: Creating Shared Understanding
Spectroscopy.pptx food analysis technology
Per capita expenditure prediction using model stacking based on satellite ima...
Programs and apps: productivity, graphics, security and other tools

The Ring programming language version 1.7 book - Part 37 of 196

  • 1. Ring Documentation, Release 1.7 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 } ) o1.print() o2.print() o3.print() Class point x y z Output: 10 20 30 100 200 300 43.25. addmethod() Function 332
  • 2. Ring Documentation, Release 1.7 50 150 250 43.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"} ] see myList see nl +"=====================" + nl + nl for i = 1 to len(myList) see "Pos: "+ i +" | "+ myList[i].position +" | "+ myList[i].name + " | "+ myList[i].symbol +" | "+ nl next See findclass(myList, "MHD", "symbol") +nl ### Specify Member class name ###--------------------------------------- func findclass classList, cValue, classMember 43.26. getattribute() function 333
  • 3. Ring Documentation, Release 1.7 See nl + "FindClass: " +" "+ cValue + nl + nl for i = 1 to len(classList) result = getattribute( classList[i], classMember ) See "Result-Attr: " + i +" "+ result +nl if result = cValue j = i ok next return j ###-------------------------------------- class company position name symbol Output: Pos: 1 | 3 | Mahmoud | MHD | Pos: 2 | 2 | Bert | BRT | Pos: 3 | 1 | Ring | RNG | FindClass: MHD Result-Attr: 1 MHD Result-Attr: 2 BRT Result-Attr: 3 RNG 1 43.27 setattribute() function We can set the object attribute value using the setattribute() function Syntax: SetAttribute(oObject,cAttributeName,Value) Example: o1 = new person setattribute(o1,"cName","Mahmoud") setattribute(o1,"nSalary",1000000) setattribute(o1,"aColors",["white","blue","yellow"]) see o1 see o1.aColors Class Person cName nSalary aColors Output: cname: Mahmoud nsalary: 1000000.000000 43.27. setattribute() function 334
  • 4. Ring Documentation, Release 1.7 acolors: List... white blue yellow 43.28 mergemethods() Function We can share methods between classes without inheritance using the MergeMethods() function This function merge class methods to another class. Syntax: MergeMethods(cClassNameDestination,cClassNameSource) Example: mergemethods("count","share") mergemethods("count2","share") o1 = new count { test() } o1 = new count2 { test() } Class Share func one see "one" + nl func two see "two" + nl func three see "three" + nl Class Display Func printline see copy("*",20) + nl Class Count from Display Func test printline() one() two() three() printline() Class Count2 from Display Func test three() two() one() printline() Output: ******************** one two three ******************** 43.28. mergemethods() Function 335
  • 5. Ring Documentation, Release 1.7 three two one ******************** 43.29 packagename() Function We can know the package name of the latest sucessful import command using the packagename() function Syntax: packagename() --> Returns the package name of the latest sucessful import Example: load "weblib.ring" import System.web see packagename() # system.web 43.29. packagename() Function 336
  • 6. CHAPTER FORTYFOUR STDLIB FUNCTIONS In this chapter we are going to learn about functions in the stdlib.ring Before using the functions in the library, We must load the library first load "stdlib.ring" Instead of using stdlib.ring we can use stdlibcore.ring Using stdlibcore.ring we can use the StdLib functions (Without Classes) This is useful when developing standalone console applications Because using stdlib.ring (functions & classes) will load libraries like RingLibCurl, RingOpenSSL, etc. 44.1 Puts() function print the value then print new line (nl) Syntax: puts(expr) Example: Load "stdlib.ring" Puts("Hello, World!") 44.2 Print() function print string - support n,t and r Also we can use #{variable_name} to insert variables values. Syntax: print(string) ---> String Example: print("nHello, WorldnnHow are you? tt I'm fine!n") x=10 y=20 print("nx value = #{x} , y value = #{y} n") 337
  • 7. Ring Documentation, Release 1.7 44.3 Print2Str() Function Syntax: print2Str(string) ---> String Example: world = "World!" mystring = print2str("Hello, #{world} nIn Year n#{2000+17} n") see mystring + nl Output: Hello, World! In Year 2017 44.4 GetString() function Get input from the keyboard - return value as string getstring() ---> string 44.5 GetNumber() function Get input from the keyboard - return value as number getnumber() ---> number 44.6 AppPath() function Get the path of the application folder Syntax: AppPath() ---> The path as String Example: Load "stdlib.ring" # Application Path Puts("Test AppPath()") See AppPath() + nl 44.7 JustFilePath() function Get the path of the file, remove the file name. 44.3. Print2Str() Function 338
  • 8. Ring Documentation, Release 1.7 Syntax: JustFilePath(cFile) ---> The path as String Example: load "stdlib.ring" see justfilePath("b:ringapplicationsrnoternote.ring") Output: b:ringapplicationsrnote 44.8 JustFileName() function Get the file, remove the file path. Syntax: JustFileName(cFile) ---> The file name as String Example: load "stdlib.ring" see justfileName("b:ringapplicationsrnoternote.ring") Output: rnote.ring 44.9 Value() function create a copy from a list or object Syntax: value(List) ---> new list Example: Load "stdlib.ring" aList = 1:10 del(value(aList),1) # delete first item see aList # print numbers from 1 to 10 44.10 Times() function Execute a Function nCount times Syntax: 44.8. JustFileName() function 339
  • 9. Ring Documentation, Release 1.7 Times(nCount,function) Example: Load "stdlib.ring" Puts("Test Times()") Times ( 3 , func { see "Hello, World!" + nl } ) 44.11 Map() function Execute a Function on each list item Syntax: Map(alist,function) ---> List Example: Load "stdlib.ring" Puts("Test Map()") See Map( 1:10, func x { return x*x } ) 44.12 Filter() function Execute a Function on each list item to filter items Syntax: Filter(alist,function) ---> List Example: Load "stdlib.ring" Puts("Test Filter()") See Filter( 1:10 , func x { if x <= 5 return true else return false ok } ) 44.13 Split() function Convert string words to list items Syntax: Split(cstring,delimiter) ---> List Example: Load "stdlib.ring" Puts("Test Split()") See Split("one two three four five"," ") 44.11. Map() function 340
  • 10. Ring Documentation, Release 1.7 44.14 SplitMany() function Convert string words to list items. Allow many delimiters. Syntax: SplitMany(cstring,delimiters as string or list) --> List Example: Load "stdlib.ring" Puts("Test SplitMany()") See SplitMany("one,two,three,four and five"," ,") 44.15 NewList() function Create a two dimensional list Syntax: NewList(nRows,nColumns) ---> new list Example: Load "stdlib.ring" Puts("Test Newlist()") a1 = 3 a2 = 5 chrArray = newlist(a1,a2) numArray = newlist(a1,a2) chrArray[1][1] = "Hello" numArray[1][1] = 987.2 See chrArray[1][1] + nl See numArray[1][1] + nl 44.16 Capitalized() function Return a copy of a string with the first letter capitalized Syntax: Capitalized(string) ---> string Example: Load "stdlib.ring" Puts("Test Capitalized()") See capitalized("welcome to the Ring Programming Language") 44.14. SplitMany() function 341