Ring Programming Language Book - Part 24 of 84
Ring Programming Language Book - Part 24 of 84
Example:
Load "stdlib.ring"
Puts("Test Evenorodd()")
nr = 17
see Evenorodd(nr) + nl
Example:
Load "stdlib.ring"
Puts("Test Factors()")
n = 45
aList = factors(n)
see "Factors of " + n + " = "
for i = 1 to len(aList)
see "" + aList[i] + " "
next
Example:
Load "stdlib.ring"
Puts("Test Palindrome()")
cString = "radar"
see Palindrome(cString)
Example:
Load "stdlib.ring"
Puts("Test Isleapyear()")
year = 2016
if Isleapyear(year) see "" + year + " is a leap year."
else see "" + year + " is not a leap year." ok
Example:
Load "stdlib.ring"
Puts("Test Binarydigits()")
b = 35
see "Binary digits of " + b + " = " + Binarydigits(b)
Example:
Load "stdlib.ring"
Syntax:
Matrixtrans(List) ---> List
Example:
Load "stdlib.ring"
Example:
Load "stdlib.ring"
Example:
Load "stdlib.ring"
Example:
Load "stdlib.ring"
Example:
Load "stdlib.ring"
Change substring from given position to a given position with another substring.
Syntax:
Changestring(cString, nPos1, nPos2, cSubstr) ---> cString
Example:
Load "stdlib.ring"
# Change substring from given position for given position with a substring.
Puts("Test Changestring()")
see Changestring("Rmasdg",2,5,"in") # Ring
Example:
Load "stdlib.ring"
Puts("Test Sleep()")
see "Wait 3 Seconds!"
Sleep(3)
see nl
Example:
Load "stdlib.ring"
if ismainsourcefile()
# code
ok
Example:
Load "stdlib.ring"
Make Directory
Syntax:
MakeDir(String)
Example:
Load "stdlib.ring"
# Create Directory
puts("create Directory : myfolder")
makedir("myfolder")
THIRTYEIGHT
STDLIB CLASSES
In this chapter we are going to learn about the classes in the stdlib.ring
StdBase Class
String Class
List Class
Stack Class
Queue Class
HashTable Class
Tree Class
Math Class
DateTime Class
File Class
System Class
Debug Class
DataType Class
Conversion Class
ODBC CLass
MySQL Class
SQLite Class
Security Class
Internet Class
Attributes:
vValue : Object Value
Methods:
216
Ring Documentation, Release 1.2
Method Description/Output
Init(x) Set vValue Attribute to x value
Print() Print vValue
PrintLn() Print vValue then New Line
Size() return number represent the size of vValue
Value() return vValue
Set(x) Call Init(x)
oString.print()
see oString.lines() + nl
oString = new String(1234)
oString.println()
oString = new String("one"+nl+"two"+nl+"three")
aList = oString.tolist()
see "List Items" + nl See aList
oString = new String( "Welcome to the Ring programming language")
See "the - position : " + oString.pos("the") + nl
oString = oString.getfrom(oString.pos("Ring"))
oString.println()
oString.mid(1,4).println()
oString = oString.replace("Ring","***Ring***",true)
oString.println()
oString = oString.replace("ring","***Ring***",false)
oString.println()
oString1 = new string("First")
oString2 = new string("Second")
oString = oString1 + oString2
oString.println()
oString = oString1 * 3
oString.println()
for t in ostring see t next
oString.tofile("test.txt")
oString = new string("one two three")
see nl
see ostring.split()
oString {
set("Hello") println()
set("How are you?") println()
}
Output:
Testing the String Class
Hello, World!
HELLO, WORLD!
hello, world!
Hello
World!
2
Welcome
Welcome
Hello! Hello! Hello!
0
1
-1
one
two
three
4
1234
List Items
one
two
three
the - position : 12
Ring programming language
Ring
***Ring*** programming language
******Ring****** programming language
FirstSecond
FirstFirstFirst
FirstFirstFirst
one
two
three
Hello
How are you?