SlideShare a Scribd company logo
Ring Documentation, Release 1.5.2
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
acolors: List...
white
blue
yellow
41.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()
41.28. mergemethods() Function 295
Ring Documentation, Release 1.5.2
Class Count2 from Display
Func test
three()
two()
one()
printline()
Output:
********************
one
two
three
********************
three
two
one
********************
41.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
41.29. packagename() Function 296
CHAPTER
FORTYTWO
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"
42.1 puts() function
print the value then print new line (nl)
Syntax:
puts(expr)
Example:
Load "stdlib.ring"
Puts("Hello, World!")
42.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")
42.3 Print2Str() Function
Syntax:
297
Ring Documentation, Release 1.5.2
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
42.4 getstring() function
Get input from the keyboard - return value as string
getstring() ---> string
42.5 getnumber() function
Get input from the keyboard - return value as number
getnumber() ---> number
42.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
42.7 justfilepath() function
Get the path of the file, remove the file name.
Syntax:
JustFilePath(cFile) ---> The path as String
42.4. getstring() function 298
Ring Documentation, Release 1.5.2
Example:
load "stdlib.ring"
see justfilePath("b:ringapplicationsrnoternote.ring")
Output:
b:ringapplicationsrnote
42.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
42.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
42.10 times() function
Execute a Function nCount times
Syntax:
Times(nCount,function)
Example:
42.8. justfilename() function 299
Ring Documentation, Release 1.5.2
Load "stdlib.ring"
Puts("Test Times()")
Times ( 3 , func { see "Hello, World!" + nl } )
42.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 } )
42.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 } )
42.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"," ")
42.11. map() function 300
Ring Documentation, Release 1.5.2
42.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"," ,")
42.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
42.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")
42.14. splitmany() function 301
Ring Documentation, Release 1.5.2
42.17 isspecial() function
Check whether a character is special or not
Syntax:
IsSpecial(char) ---> True/False
Example:
Load "stdlib.ring"
Puts("Test Isspecial()")
See "Isspecial = " + isSpecial("%") + nl
42.18 isvowel() function
Check whether a character is vowel or not
Syntax:
IsVowel(char) ---> True/False
Example:
Load "stdlib.ring"
Puts("Test Isvowel()")
See "Isvowel = " + isVowel("c") + nl
42.19 linecount() function
Return the lines count in a text file.
Syntax:
LineCount(cFileName) ---> Lines Count as number
Example:
Load "stdlib.ring"
Puts("Test Linecount()")
See "the number of lines = " + lineCount("test.ring")
42.20 factorial() function
Return the factorial of a number
Syntax:
Factorial(number) ---> number
Example:
42.17. isspecial() function 302
Ring Documentation, Release 1.5.2
Load "stdlib.ring"
Puts("Test Factorial()")
see "6 factorial is : " + Factorial(6)
42.21 fibonacci() function
Return the fibonacci number
Syntax:
Fibonacci(number) ---> number
Example:
Load "stdlib.ring"
Puts("Test Fibonacci()")
see "6 Fibonacci is : " + Fibonacci(6)
42.22 isprime() function
Check whether a number is prime or not
Syntax:
isprime(number) ---> Number
Example:
Load "stdlib.ring"
Puts("Test Isprime()")
if isPrime(16) see "16 is a prime number"
else see "16 is not a prime number" ok
42.23 sign() function
Returns an integer value indicating the sign of a number.
Syntax:
Sign(number) ---> number ( -1 = negative , 0 , 1 (positive) )
Example:
Load "stdlib.ring"
Puts("Test Sign()")
see "sign of 12 is = " + sign(12) + nl
42.21. fibonacci() function 303
Ring Documentation, Release 1.5.2
42.24 list2file() function
Write list items to text file (each item in new line).
Syntax:
List2File(aList,cFileName)
Example:
Load "stdlib.ring"
# Test List2File
Puts("Test List2File()")
list2file(1:100,"myfile.txt")
42.25 file2list() function
Read text file and convert lines to list items
Syntax:
File2List(cFileName) ---> List
Example:
Load "stdlib.ring"
# Test File2List
Puts("Test File2List()")
see len(file2list("myfile.txt"))
42.26 startswith() function
Returns true if the given string starts with the specified substring.
Leading white spaces are ignored.
Syntax:
StartsWith(string, substring) ---> True/False
Example:
Load "stdlib.ring"
Puts("Test Startswith()")
see Startswith("CalmoSoft", "Calmo") + nl
42.27 endswith() function
Returns true if the given string ends with the specified substring.
Trailing white spaces are ignored.
42.24. list2file() function 304

More Related Content

PDF
The Ring programming language version 1.2 book - Part 23 of 84
PDF
The Ring programming language version 1.5.3 book - Part 33 of 184
PDF
The Ring programming language version 1.9 book - Part 41 of 210
PDF
The Ring programming language version 1.5.4 book - Part 33 of 185
PDF
The Ring programming language version 1.6 book - Part 35 of 189
PDF
The Ring programming language version 1.3 book - Part 24 of 88
PDF
The Ring programming language version 1.7 book - Part 37 of 196
PDF
The Ring programming language version 1.5.4 book - Part 34 of 185
The Ring programming language version 1.2 book - Part 23 of 84
The Ring programming language version 1.5.3 book - Part 33 of 184
The Ring programming language version 1.9 book - Part 41 of 210
The Ring programming language version 1.5.4 book - Part 33 of 185
The Ring programming language version 1.6 book - Part 35 of 189
The Ring programming language version 1.3 book - Part 24 of 88
The Ring programming language version 1.7 book - Part 37 of 196
The Ring programming language version 1.5.4 book - Part 34 of 185

What's hot (20)

PDF
The Ring programming language version 1.10 book - Part 43 of 212
PDF
The Ring programming language version 1.5.3 book - Part 34 of 184
PDF
The Ring programming language version 1.5.2 book - Part 32 of 181
PDF
The Ring programming language version 1.5 book - Part 6 of 31
PDF
The Ring programming language version 1.9 book - Part 42 of 210
PDF
7 Habits For a More Functional Swift
PDF
The Ring programming language version 1.2 book - Part 22 of 84
PDF
The Ring programming language version 1.5.1 book - Part 32 of 180
PDF
The Ring programming language version 1.5.1 book - Part 29 of 180
PDF
The Ring programming language version 1.7 book - Part 34 of 196
PDF
The Ring programming language version 1.6 book - Part 183 of 189
PPTX
Groovy grails types, operators, objects
PDF
The Ring programming language version 1.5.3 book - Part 44 of 184
PDF
The Ring programming language version 1.4.1 book - Part 9 of 31
PDF
The Ring programming language version 1.6 book - Part 36 of 189
PDF
The Ring programming language version 1.4 book - Part 9 of 30
PPTX
Introduction to Monads in Scala (1)
PDF
The Ring programming language version 1.5.2 book - Part 35 of 181
PDF
The Ring programming language version 1.6 book - Part 39 of 189
PDF
The Ring programming language version 1.9 book - Part 38 of 210
The Ring programming language version 1.10 book - Part 43 of 212
The Ring programming language version 1.5.3 book - Part 34 of 184
The Ring programming language version 1.5.2 book - Part 32 of 181
The Ring programming language version 1.5 book - Part 6 of 31
The Ring programming language version 1.9 book - Part 42 of 210
7 Habits For a More Functional Swift
The Ring programming language version 1.2 book - Part 22 of 84
The Ring programming language version 1.5.1 book - Part 32 of 180
The Ring programming language version 1.5.1 book - Part 29 of 180
The Ring programming language version 1.7 book - Part 34 of 196
The Ring programming language version 1.6 book - Part 183 of 189
Groovy grails types, operators, objects
The Ring programming language version 1.5.3 book - Part 44 of 184
The Ring programming language version 1.4.1 book - Part 9 of 31
The Ring programming language version 1.6 book - Part 36 of 189
The Ring programming language version 1.4 book - Part 9 of 30
Introduction to Monads in Scala (1)
The Ring programming language version 1.5.2 book - Part 35 of 181
The Ring programming language version 1.6 book - Part 39 of 189
The Ring programming language version 1.9 book - Part 38 of 210
Ad

Similar to The Ring programming language version 1.5.2 book - Part 33 of 181 (20)

PDF
The Ring programming language version 1.8 book - Part 39 of 202
PDF
The Ring programming language version 1.3 book - Part 25 of 88
PDF
The Ring programming language version 1.7 book - Part 38 of 196
PDF
The Ring programming language version 1.10 book - Part 44 of 212
PDF
The Ring programming language version 1.5.2 book - Part 34 of 181
PDF
The Ring programming language version 1.6 book - Part 37 of 189
PDF
The Ring programming language version 1.5.4 book - Part 35 of 185
PDF
The Ring programming language version 1.5.1 book - Part 33 of 180
PDF
The Ring programming language version 1.2 book - Part 24 of 84
PDF
The Ring programming language version 1.8 book - Part 40 of 202
PDF
The Ring programming language version 1.9 book - Part 43 of 210
PDF
The Ring programming language version 1.3 book - Part 26 of 88
PDF
The Ring programming language version 1.5.1 book - Part 35 of 180
PDF
The Ring programming language version 1.6 book - Part 34 of 189
PDF
The Ring programming language version 1.4 book - Part 6 of 30
PDF
The Ring programming language version 1.8 book - Part 29 of 202
PDF
The Ring programming language version 1.5.4 book - Part 32 of 185
PDF
The Ring programming language version 1.5.3 book - Part 35 of 184
PDF
The Ring programming language version 1.5.4 book - Part 24 of 185
PDF
The Ring programming language version 1.5.3 book - Part 24 of 184
The Ring programming language version 1.8 book - Part 39 of 202
The Ring programming language version 1.3 book - Part 25 of 88
The Ring programming language version 1.7 book - Part 38 of 196
The Ring programming language version 1.10 book - Part 44 of 212
The Ring programming language version 1.5.2 book - Part 34 of 181
The Ring programming language version 1.6 book - Part 37 of 189
The Ring programming language version 1.5.4 book - Part 35 of 185
The Ring programming language version 1.5.1 book - Part 33 of 180
The Ring programming language version 1.2 book - Part 24 of 84
The Ring programming language version 1.8 book - Part 40 of 202
The Ring programming language version 1.9 book - Part 43 of 210
The Ring programming language version 1.3 book - Part 26 of 88
The Ring programming language version 1.5.1 book - Part 35 of 180
The Ring programming language version 1.6 book - Part 34 of 189
The Ring programming language version 1.4 book - Part 6 of 30
The Ring programming language version 1.8 book - Part 29 of 202
The Ring programming language version 1.5.4 book - Part 32 of 185
The Ring programming language version 1.5.3 book - Part 35 of 184
The Ring programming language version 1.5.4 book - Part 24 of 185
The Ring programming language version 1.5.3 book - Part 24 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
Encapsulation_ Review paper, used for researhc scholars
PDF
Getting Started with Data Integration: FME Form 101
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PPT
Teaching material agriculture food technology
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
cloud_computing_Infrastucture_as_cloud_p
PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PPTX
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Empathic Computing: Creating Shared Understanding
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
Encapsulation_ Review paper, used for researhc scholars
Getting Started with Data Integration: FME Form 101
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Teaching material agriculture food technology
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Accuracy of neural networks in brain wave diagnosis of schizophrenia
Digital-Transformation-Roadmap-for-Companies.pptx
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Group 1 Presentation -Planning and Decision Making .pptx
Mobile App Security Testing_ A Comprehensive Guide.pdf
cloud_computing_Infrastucture_as_cloud_p
SOPHOS-XG Firewall Administrator PPT.pptx
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Empathic Computing: Creating Shared Understanding
Unlocking AI with Model Context Protocol (MCP)
Per capita expenditure prediction using model stacking based on satellite ima...
Network Security Unit 5.pdf for BCA BBA.
Univ-Connecticut-ChatGPT-Presentaion.pdf

The Ring programming language version 1.5.2 book - Part 33 of 181

  • 1. Ring Documentation, Release 1.5.2 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 acolors: List... white blue yellow 41.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() 41.28. mergemethods() Function 295
  • 2. Ring Documentation, Release 1.5.2 Class Count2 from Display Func test three() two() one() printline() Output: ******************** one two three ******************** three two one ******************** 41.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 41.29. packagename() Function 296
  • 3. CHAPTER FORTYTWO 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" 42.1 puts() function print the value then print new line (nl) Syntax: puts(expr) Example: Load "stdlib.ring" Puts("Hello, World!") 42.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") 42.3 Print2Str() Function Syntax: 297
  • 4. Ring Documentation, Release 1.5.2 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 42.4 getstring() function Get input from the keyboard - return value as string getstring() ---> string 42.5 getnumber() function Get input from the keyboard - return value as number getnumber() ---> number 42.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 42.7 justfilepath() function Get the path of the file, remove the file name. Syntax: JustFilePath(cFile) ---> The path as String 42.4. getstring() function 298
  • 5. Ring Documentation, Release 1.5.2 Example: load "stdlib.ring" see justfilePath("b:ringapplicationsrnoternote.ring") Output: b:ringapplicationsrnote 42.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 42.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 42.10 times() function Execute a Function nCount times Syntax: Times(nCount,function) Example: 42.8. justfilename() function 299
  • 6. Ring Documentation, Release 1.5.2 Load "stdlib.ring" Puts("Test Times()") Times ( 3 , func { see "Hello, World!" + nl } ) 42.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 } ) 42.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 } ) 42.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"," ") 42.11. map() function 300
  • 7. Ring Documentation, Release 1.5.2 42.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"," ,") 42.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 42.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") 42.14. splitmany() function 301
  • 8. Ring Documentation, Release 1.5.2 42.17 isspecial() function Check whether a character is special or not Syntax: IsSpecial(char) ---> True/False Example: Load "stdlib.ring" Puts("Test Isspecial()") See "Isspecial = " + isSpecial("%") + nl 42.18 isvowel() function Check whether a character is vowel or not Syntax: IsVowel(char) ---> True/False Example: Load "stdlib.ring" Puts("Test Isvowel()") See "Isvowel = " + isVowel("c") + nl 42.19 linecount() function Return the lines count in a text file. Syntax: LineCount(cFileName) ---> Lines Count as number Example: Load "stdlib.ring" Puts("Test Linecount()") See "the number of lines = " + lineCount("test.ring") 42.20 factorial() function Return the factorial of a number Syntax: Factorial(number) ---> number Example: 42.17. isspecial() function 302
  • 9. Ring Documentation, Release 1.5.2 Load "stdlib.ring" Puts("Test Factorial()") see "6 factorial is : " + Factorial(6) 42.21 fibonacci() function Return the fibonacci number Syntax: Fibonacci(number) ---> number Example: Load "stdlib.ring" Puts("Test Fibonacci()") see "6 Fibonacci is : " + Fibonacci(6) 42.22 isprime() function Check whether a number is prime or not Syntax: isprime(number) ---> Number Example: Load "stdlib.ring" Puts("Test Isprime()") if isPrime(16) see "16 is a prime number" else see "16 is not a prime number" ok 42.23 sign() function Returns an integer value indicating the sign of a number. Syntax: Sign(number) ---> number ( -1 = negative , 0 , 1 (positive) ) Example: Load "stdlib.ring" Puts("Test Sign()") see "sign of 12 is = " + sign(12) + nl 42.21. fibonacci() function 303
  • 10. Ring Documentation, Release 1.5.2 42.24 list2file() function Write list items to text file (each item in new line). Syntax: List2File(aList,cFileName) Example: Load "stdlib.ring" # Test List2File Puts("Test List2File()") list2file(1:100,"myfile.txt") 42.25 file2list() function Read text file and convert lines to list items Syntax: File2List(cFileName) ---> List Example: Load "stdlib.ring" # Test File2List Puts("Test File2List()") see len(file2list("myfile.txt")) 42.26 startswith() function Returns true if the given string starts with the specified substring. Leading white spaces are ignored. Syntax: StartsWith(string, substring) ---> True/False Example: Load "stdlib.ring" Puts("Test Startswith()") see Startswith("CalmoSoft", "Calmo") + nl 42.27 endswith() function Returns true if the given string ends with the specified substring. Trailing white spaces are ignored. 42.24. list2file() function 304