SlideShare a Scribd company logo
Ring Documentation, Release 1.6
see "" + aList[i] + " "
next
43.34 Palindrome() function
Check if a sequence of characters is a palindrome or not.
Syntax:
Palindrome(String) ---> True/False
Example:
Load "stdlib.ring"
Puts("Test Palindrome()")
cString = "radar"
see Palindrome(cString)
43.35 IsLeapYear() function
Check whether a given year is a leap year in the Gregorian calendar.
Syntax:
Isleapyear(number) ---> True/False
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
43.36 BinaryDigits() function
Compute the sequence of binary digits for a given non-negative integer.
Syntax:
binarydigits(number) ---> string
Example:
Load "stdlib.ring"
Puts("Test Binarydigits()")
b = 35
see "Binary digits of " + b + " = " + Binarydigits(b)
43.34. Palindrome() function 333
Ring Documentation, Release 1.6
43.37 MatrixMulti() function
Multiply two matrices together.
Syntax:
Matrixmulti(List,List) ---> List
Example:
Load "stdlib.ring"
# Multiply two matrices together.
Puts("Test Matrixmulti()")
A = [[1,2,3], [4,5,6], [7,8,9]]
B = [[1,0,0], [0,1,0], [0,0,1]]
see Matrixmulti(A, B)
43.38 MatrixTrans() function
Transpose an arbitrarily sized rectangular Matrix.
Syntax:
Matrixtrans(List) ---> List
Example:
Load "stdlib.ring"
# Transpose an arbitrarily sized rectangular Matrix.
Puts("Test Matrixtrans()")
matrix = [[78,19,30,12,36], [49,10,65,42,50], [30,93,24,78,10], [39,68,27,64,29]]
see Matrixtrans(matrix)
43.39 DayOfWeek() function
Return the day of the week of given date. (yyyy-mm-dd)
Syntax:
dayofweek(string) ---> string
Example:
Load "stdlib.ring"
# Return the day of the week of given date.
Puts("Test Dayofweek()")
date = "2016-04-24"
see "Data : " + date + " - Day : " + Dayofweek(date) + nl
43.37. MatrixMulti() function 334
Ring Documentation, Release 1.6
43.40 Permutation() function
Generates all permutations of n different numerals.
Syntax:
permutation(list)
Example:
Load "stdlib.ring"
# Generates all permutations of n different numerals
Puts("Test Permutation()")
list = [1, 2, 3, 4]
for perm = 1 to 24
for i = 1 to len(list)
see list[i] + " "
next
see nl
Permutation(list)
next
43.41 ReadLine() function
Read line from file
Syntax:
readline(fp) ---> string
Example:
Load "stdlib.ring"
# Read a file line by line.
Puts("Test Readline()")
fp = fopen("test.ring","r")
while not feof(fp)
See Readline(fp) end
fclose(fp)
43.42 SubString() function
Return a position of a substring starting from a given position in a string.
Syntax:
Substring(str,substr,npos) ---> string
Example:
Load "stdlib.ring"
# Return a position of a substring starting from a given position in a string.
43.40. Permutation() function 335
Ring Documentation, Release 1.6
Puts("Test Substring()")
a = "abcxyzqweabc"
b = "abc"
i = 4
see substring(a,b,i)
43.43 ChangeString() function
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
43.44 Sleep() function
Sleep for the given amount of time.
Syntax:
sleep(nSeconds)
Example:
Load "stdlib.ring"
Puts("Test Sleep()")
see "Wait 3 Seconds!"
Sleep(3)
see nl
43.45 IsMainSourceFile() function
Check if the current file is the main source file
Syntax:
IsMainSourceFile() ---> True/False
Example:
Load "stdlib.ring"
if ismainsourcefile()
# code
ok
43.43. ChangeString() function 336
Ring Documentation, Release 1.6
43.46 DirExists() function
Check if directory exists
Syntax:
DirExists(String) ---> True/False
Example:
Load "stdlib.ring"
see "Check dir : b:ring "
puts( DirExists("b:ring") )
see "Check dir : C:ring "
Puts( DirExists("C:ring") )
43.47 MakeDir() function
Make Directory
Syntax:
MakeDir(String)
Example:
Load "stdlib.ring"
# Create Directory
puts("create Directory : myfolder")
makedir("myfolder")
43.48 Fsize() function
The function return the file size in bytes.
Syntax:
FSize(File Handle) ---> Number (File Size in Bytes)
43.49 TrimAll() function
Remove all spaces and tabs characters from a string
Syntax:
TrimAll(cString) ---> cString # Without Spaces and Tabs
43.46. DirExists() function 337
Ring Documentation, Release 1.6
43.50 TrimLeft() function
Remove all spaces and tabs characters from the left side of a string
Syntax:
TrimLeft(cString) ---> cString # Without Spaces and Tabs from the left side
43.51 TrimRight() function
Remove all spaces and tabs characters from the right side of a string
Syntax:
TrimRight(cString) ---> cString # Without Spaces and Tabs from the right side
43.52 EpochTime() function
Return the Epoch Time
Syntax:
EpochTime(cDate,cTime) ---> nEpochTime
Example:
see EpochTime( Date(), Time() )
43.53 SystemCmd() Function
We can execute system commands using the SystemCmd() function that outputs to a variable
Syntax:
SystemCmd(cCommand)
Example:
cYou = SystemCmd("whoami") # User Name logged in is output a variable
cThem = SystemCmd("dir c:Users") # Directory List is output to a variable
43.54 ListAllFiles() Function
Using this function we can quickly do a process on a group of files in a folder and it’s sub folders.
Syntax:
ListAllFiles(cFolder,cExtension) ---> List of Files
Example:
43.50. TrimLeft() function 338
Ring Documentation, Release 1.6
aList = ListAllFiles("c:/ring/ringlibs","ring") # *.ring only
aList = sort(aList)
see aList
Example:
see listallfiles("b:/ring/ringlibs/weblib","") # All Files
43.55 SystemSilent() Function
We can execute system commands using the SystemSilent() function to avoid displaying the output!
Syntax:
SystemSilent(cCommand)
43.56 OSCreateOpenFolder() Function
Create folder then change the current folder to this new folder
Syntax:
OSCreateOpenFolder(cCommand)
43.57 OSCopyFolder() Function
Copy folder to the current folder
Parameters : The path to the parent folder and the folder name to copy
Syntax:
OSCopyFolder(cParentFolder,cFolderName)
Example
To copy the folder b:ringringlibsstdlib to the current folder
OSCopyFolder("b:ringringlibs","stdlib")
43.58 OSDeleteFolder() Function
Delete Folder in the current Directory
Syntax:
OSDeleteFolder(cFolderName)
43.55. SystemSilent() Function 339
Ring Documentation, Release 1.6
43.59 OSCopyFile() Function
Copy File to the current directory
Syntax:
OSCopyFile(cFileName)
43.60 OSDeleteFile() Function
Delete File
Syntax:
OSDeleteFile(cFileName)
43.61 OSRenameFile() Function
Rename File
Syntax:
OSRenameFile(cOldFileName,cNewFileName)
43.59. OSCopyFile() Function 340
CHAPTER
FORTYFOUR
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
44.1 StdBase Class
Attributes:
• vValue : Object Value
Methods:
341
Ring Documentation, Release 1.6
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)
44.2 String Class
Parent Class : StdBase Class
Methods:
Method Description/Output
Init(String|Number|List)
Lower() New String - Lower case characters
Upper() New String - Upper case characters
Left(x) New String - contains x characters from the left
Right(x) New String - contains x characters from the right
Lines() Number - Lines count
Trim() New String - Remove Spaces
Copy(x) New String - repeat string x times
strcmp(cString) Compare string with cString
tolist() List (String Lines to String Items)
tofile(cFileName) Write string to file
mid(nPos1,nPos2) New String - from nPos1 to nPos2
getfrom(nPos1) New String - from nPos1 to the end of the string
replace(cStr1,cStr2,lCase) New String - Replace cStr1 with cStr2 , lCase (True=Match Case)
split() List - Each Word as list item
startswith(substring) Return true if the start starts with a substring
endswith(substring) Return true if the start ends with a substring
Example:
Load "stdlib.ring"
See "Testing the String Class" + nl
oString = new string("Hello, World!")
oString.println()
oString.upper().println()
oString.lower().println()
oString.left(5).println()
oString.right(6).println()
oString = new string("Hi" + nl + "Hello" )
See oString.lines() + nl
oString = new string(" Welcome ")
oString.println()
oString.trim().println()
oString = new string("Hello! ")
oString.copy(3).println()
see oString.strcmp("Hello! ") + nl
see oString.strcmp("Hello ") + nl
see oString.strcmp("Hello!! ") + nl
oString = new string(["one","two","three"])
44.2. String Class 342

More Related Content

PDF
The Ring programming language version 1.8 book - Part 40 of 202
PDF
The Ring programming language version 1.5.4 book - Part 35 of 185
PDF
The Ring programming language version 1.4.1 book - Part 10 of 31
PDF
The Ring programming language version 1.2 book - Part 24 of 84
PDF
The Ring programming language version 1.3 book - Part 26 of 88
PDF
The Ring programming language version 1.5.3 book - Part 35 of 184
PDF
The Ring programming language version 1.5.2 book - Part 34 of 181
PDF
The Ring programming language version 1.10 book - Part 45 of 212
The Ring programming language version 1.8 book - Part 40 of 202
The Ring programming language version 1.5.4 book - Part 35 of 185
The Ring programming language version 1.4.1 book - Part 10 of 31
The Ring programming language version 1.2 book - Part 24 of 84
The Ring programming language version 1.3 book - Part 26 of 88
The Ring programming language version 1.5.3 book - Part 35 of 184
The Ring programming language version 1.5.2 book - Part 34 of 181
The Ring programming language version 1.10 book - Part 45 of 212

What's hot (20)

PDF
The Ring programming language version 1.7 book - Part 38 of 196
PDF
The Ring programming language version 1.7 book - Part 39 of 196
PDF
The Ring programming language version 1.5.2 book - Part 35 of 181
PDF
The Ring programming language version 1.8 book - Part 39 of 202
PDF
The Ring programming language version 1.5.3 book - Part 34 of 184
PDF
The Ring programming language version 1.10 book - Part 43 of 212
PDF
The Ring programming language version 1.5.2 book - Part 33 of 181
PDF
The Ring programming language version 1.9 book - Part 42 of 210
PDF
The Ring programming language version 1.3 book - Part 25 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
PPTX
Chap2 class,objects contd
PDF
The Ring programming language version 1.4.1 book - Part 9 of 31
PDF
The Ring programming language version 1.8 book - Part 94 of 202
PDF
Scala for Java Developers - Intro
PDF
Futures e abstração - QCon São Paulo 2015
PDF
Meet scala
PDF
The... Wonderful? World of Lambdas
PDF
The Ring programming language version 1.7 book - Part 34 of 196
PDF
The Ring programming language version 1.9 book - Part 123 of 210
The Ring programming language version 1.7 book - Part 38 of 196
The Ring programming language version 1.7 book - Part 39 of 196
The Ring programming language version 1.5.2 book - Part 35 of 181
The Ring programming language version 1.8 book - Part 39 of 202
The Ring programming language version 1.5.3 book - Part 34 of 184
The Ring programming language version 1.10 book - Part 43 of 212
The Ring programming language version 1.5.2 book - Part 33 of 181
The Ring programming language version 1.9 book - Part 42 of 210
The Ring programming language version 1.3 book - Part 25 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
Chap2 class,objects contd
The Ring programming language version 1.4.1 book - Part 9 of 31
The Ring programming language version 1.8 book - Part 94 of 202
Scala for Java Developers - Intro
Futures e abstração - QCon São Paulo 2015
Meet scala
The... Wonderful? World of Lambdas
The Ring programming language version 1.7 book - Part 34 of 196
The Ring programming language version 1.9 book - Part 123 of 210
Ad

Similar to The Ring programming language version 1.6 book - Part 37 of 189 (20)

PDF
The Ring programming language version 1.5.1 book - Part 33 of 180
PDF
The Ring programming language version 1.9 book - Part 43 of 210
PDF
The Ring programming language version 1.6 book - Part 36 of 189
PDF
The Ring programming language version 1.10 book - Part 44 of 212
PDF
The Ring programming language version 1.2 book - Part 23 of 84
PDF
The Ring programming language version 1.5.1 book - Part 32 of 180
PDF
The Ring programming language version 1.4 book - Part 6 of 30
PDF
The Ring programming language version 1.5.1 book - Part 35 of 180
PDF
The Ring programming language version 1.5.4 book - Part 24 of 185
PDF
The Ring programming language version 1.8 book - Part 29 of 202
PDF
The Ring programming language version 1.5.4 book - Part 37 of 185
PDF
The Ring programming language version 1.9 book - Part 31 of 210
PDF
The Ring programming language version 1.2 book - Part 26 of 84
PDF
The Ring programming language version 1.10 book - Part 32 of 212
PDF
The Ring programming language version 1.6 book - Part 26 of 189
PDF
The Ring programming language version 1.2 book - Part 13 of 84
PDF
The Ring programming language version 1.5.2 book - Part 23 of 181
PDF
The Ring programming language version 1.4.1 book - Part 6 of 31
PDF
The Ring programming language version 1.5.2 book - Part 36 of 181
PDF
The Ring programming language version 1.6 book - Part 39 of 189
The Ring programming language version 1.5.1 book - Part 33 of 180
The Ring programming language version 1.9 book - Part 43 of 210
The Ring programming language version 1.6 book - Part 36 of 189
The Ring programming language version 1.10 book - Part 44 of 212
The Ring programming language version 1.2 book - Part 23 of 84
The Ring programming language version 1.5.1 book - Part 32 of 180
The Ring programming language version 1.4 book - Part 6 of 30
The Ring programming language version 1.5.1 book - Part 35 of 180
The Ring programming language version 1.5.4 book - Part 24 of 185
The Ring programming language version 1.8 book - Part 29 of 202
The Ring programming language version 1.5.4 book - Part 37 of 185
The Ring programming language version 1.9 book - Part 31 of 210
The Ring programming language version 1.2 book - Part 26 of 84
The Ring programming language version 1.10 book - Part 32 of 212
The Ring programming language version 1.6 book - Part 26 of 189
The Ring programming language version 1.2 book - Part 13 of 84
The Ring programming language version 1.5.2 book - Part 23 of 181
The Ring programming language version 1.4.1 book - Part 6 of 31
The Ring programming language version 1.5.2 book - Part 36 of 181
The Ring programming language version 1.6 book - Part 39 of 189
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
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
System and Network Administration Chapter 2
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
How Creative Agencies Leverage Project Management Software.pdf
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
System and Network Administraation Chapter 3
PPTX
ai tools demonstartion for schools and inter college
PPTX
L1 - Introduction to python Backend.pptx
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Navsoft: AI-Powered Business Solutions & Custom Software Development
How to Choose the Right IT Partner for Your Business in Malaysia
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Odoo Companies in India – Driving Business Transformation.pdf
System and Network Administration Chapter 2
CHAPTER 2 - PM Management and IT Context
wealthsignaloriginal-com-DS-text-... (1).pdf
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Reimagine Home Health with the Power of Agentic AI​
How Creative Agencies Leverage Project Management Software.pdf
Design an Analysis of Algorithms II-SECS-1021-03
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
System and Network Administraation Chapter 3
ai tools demonstartion for schools and inter college
L1 - Introduction to python Backend.pptx
Adobe Illustrator 28.6 Crack My Vision of Vector Design

The Ring programming language version 1.6 book - Part 37 of 189

  • 1. Ring Documentation, Release 1.6 see "" + aList[i] + " " next 43.34 Palindrome() function Check if a sequence of characters is a palindrome or not. Syntax: Palindrome(String) ---> True/False Example: Load "stdlib.ring" Puts("Test Palindrome()") cString = "radar" see Palindrome(cString) 43.35 IsLeapYear() function Check whether a given year is a leap year in the Gregorian calendar. Syntax: Isleapyear(number) ---> True/False 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 43.36 BinaryDigits() function Compute the sequence of binary digits for a given non-negative integer. Syntax: binarydigits(number) ---> string Example: Load "stdlib.ring" Puts("Test Binarydigits()") b = 35 see "Binary digits of " + b + " = " + Binarydigits(b) 43.34. Palindrome() function 333
  • 2. Ring Documentation, Release 1.6 43.37 MatrixMulti() function Multiply two matrices together. Syntax: Matrixmulti(List,List) ---> List Example: Load "stdlib.ring" # Multiply two matrices together. Puts("Test Matrixmulti()") A = [[1,2,3], [4,5,6], [7,8,9]] B = [[1,0,0], [0,1,0], [0,0,1]] see Matrixmulti(A, B) 43.38 MatrixTrans() function Transpose an arbitrarily sized rectangular Matrix. Syntax: Matrixtrans(List) ---> List Example: Load "stdlib.ring" # Transpose an arbitrarily sized rectangular Matrix. Puts("Test Matrixtrans()") matrix = [[78,19,30,12,36], [49,10,65,42,50], [30,93,24,78,10], [39,68,27,64,29]] see Matrixtrans(matrix) 43.39 DayOfWeek() function Return the day of the week of given date. (yyyy-mm-dd) Syntax: dayofweek(string) ---> string Example: Load "stdlib.ring" # Return the day of the week of given date. Puts("Test Dayofweek()") date = "2016-04-24" see "Data : " + date + " - Day : " + Dayofweek(date) + nl 43.37. MatrixMulti() function 334
  • 3. Ring Documentation, Release 1.6 43.40 Permutation() function Generates all permutations of n different numerals. Syntax: permutation(list) Example: Load "stdlib.ring" # Generates all permutations of n different numerals Puts("Test Permutation()") list = [1, 2, 3, 4] for perm = 1 to 24 for i = 1 to len(list) see list[i] + " " next see nl Permutation(list) next 43.41 ReadLine() function Read line from file Syntax: readline(fp) ---> string Example: Load "stdlib.ring" # Read a file line by line. Puts("Test Readline()") fp = fopen("test.ring","r") while not feof(fp) See Readline(fp) end fclose(fp) 43.42 SubString() function Return a position of a substring starting from a given position in a string. Syntax: Substring(str,substr,npos) ---> string Example: Load "stdlib.ring" # Return a position of a substring starting from a given position in a string. 43.40. Permutation() function 335
  • 4. Ring Documentation, Release 1.6 Puts("Test Substring()") a = "abcxyzqweabc" b = "abc" i = 4 see substring(a,b,i) 43.43 ChangeString() function 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 43.44 Sleep() function Sleep for the given amount of time. Syntax: sleep(nSeconds) Example: Load "stdlib.ring" Puts("Test Sleep()") see "Wait 3 Seconds!" Sleep(3) see nl 43.45 IsMainSourceFile() function Check if the current file is the main source file Syntax: IsMainSourceFile() ---> True/False Example: Load "stdlib.ring" if ismainsourcefile() # code ok 43.43. ChangeString() function 336
  • 5. Ring Documentation, Release 1.6 43.46 DirExists() function Check if directory exists Syntax: DirExists(String) ---> True/False Example: Load "stdlib.ring" see "Check dir : b:ring " puts( DirExists("b:ring") ) see "Check dir : C:ring " Puts( DirExists("C:ring") ) 43.47 MakeDir() function Make Directory Syntax: MakeDir(String) Example: Load "stdlib.ring" # Create Directory puts("create Directory : myfolder") makedir("myfolder") 43.48 Fsize() function The function return the file size in bytes. Syntax: FSize(File Handle) ---> Number (File Size in Bytes) 43.49 TrimAll() function Remove all spaces and tabs characters from a string Syntax: TrimAll(cString) ---> cString # Without Spaces and Tabs 43.46. DirExists() function 337
  • 6. Ring Documentation, Release 1.6 43.50 TrimLeft() function Remove all spaces and tabs characters from the left side of a string Syntax: TrimLeft(cString) ---> cString # Without Spaces and Tabs from the left side 43.51 TrimRight() function Remove all spaces and tabs characters from the right side of a string Syntax: TrimRight(cString) ---> cString # Without Spaces and Tabs from the right side 43.52 EpochTime() function Return the Epoch Time Syntax: EpochTime(cDate,cTime) ---> nEpochTime Example: see EpochTime( Date(), Time() ) 43.53 SystemCmd() Function We can execute system commands using the SystemCmd() function that outputs to a variable Syntax: SystemCmd(cCommand) Example: cYou = SystemCmd("whoami") # User Name logged in is output a variable cThem = SystemCmd("dir c:Users") # Directory List is output to a variable 43.54 ListAllFiles() Function Using this function we can quickly do a process on a group of files in a folder and it’s sub folders. Syntax: ListAllFiles(cFolder,cExtension) ---> List of Files Example: 43.50. TrimLeft() function 338
  • 7. Ring Documentation, Release 1.6 aList = ListAllFiles("c:/ring/ringlibs","ring") # *.ring only aList = sort(aList) see aList Example: see listallfiles("b:/ring/ringlibs/weblib","") # All Files 43.55 SystemSilent() Function We can execute system commands using the SystemSilent() function to avoid displaying the output! Syntax: SystemSilent(cCommand) 43.56 OSCreateOpenFolder() Function Create folder then change the current folder to this new folder Syntax: OSCreateOpenFolder(cCommand) 43.57 OSCopyFolder() Function Copy folder to the current folder Parameters : The path to the parent folder and the folder name to copy Syntax: OSCopyFolder(cParentFolder,cFolderName) Example To copy the folder b:ringringlibsstdlib to the current folder OSCopyFolder("b:ringringlibs","stdlib") 43.58 OSDeleteFolder() Function Delete Folder in the current Directory Syntax: OSDeleteFolder(cFolderName) 43.55. SystemSilent() Function 339
  • 8. Ring Documentation, Release 1.6 43.59 OSCopyFile() Function Copy File to the current directory Syntax: OSCopyFile(cFileName) 43.60 OSDeleteFile() Function Delete File Syntax: OSDeleteFile(cFileName) 43.61 OSRenameFile() Function Rename File Syntax: OSRenameFile(cOldFileName,cNewFileName) 43.59. OSCopyFile() Function 340
  • 9. CHAPTER FORTYFOUR 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 44.1 StdBase Class Attributes: • vValue : Object Value Methods: 341
  • 10. Ring Documentation, Release 1.6 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) 44.2 String Class Parent Class : StdBase Class Methods: Method Description/Output Init(String|Number|List) Lower() New String - Lower case characters Upper() New String - Upper case characters Left(x) New String - contains x characters from the left Right(x) New String - contains x characters from the right Lines() Number - Lines count Trim() New String - Remove Spaces Copy(x) New String - repeat string x times strcmp(cString) Compare string with cString tolist() List (String Lines to String Items) tofile(cFileName) Write string to file mid(nPos1,nPos2) New String - from nPos1 to nPos2 getfrom(nPos1) New String - from nPos1 to the end of the string replace(cStr1,cStr2,lCase) New String - Replace cStr1 with cStr2 , lCase (True=Match Case) split() List - Each Word as list item startswith(substring) Return true if the start starts with a substring endswith(substring) Return true if the start ends with a substring Example: Load "stdlib.ring" See "Testing the String Class" + nl oString = new string("Hello, World!") oString.println() oString.upper().println() oString.lower().println() oString.left(5).println() oString.right(6).println() oString = new string("Hi" + nl + "Hello" ) See oString.lines() + nl oString = new string(" Welcome ") oString.println() oString.trim().println() oString = new string("Hello! ") oString.copy(3).println() see oString.strcmp("Hello! ") + nl see oString.strcmp("Hello ") + nl see oString.strcmp("Hello!! ") + nl oString = new string(["one","two","three"]) 44.2. String Class 342