SlideShare a Scribd company logo
Ring Documentation, Release 1.9
Syntax:
Endswith(string, substring) ---> True/False
Example:
Load "stdlib.ring"
Puts("Test Endswith()")
see endsWith("CalmoSoft", "Soft") + nl
47.28 GCD() function
Finding of the greatest common divisor of two integers.
Syntax:
Gcd(number,number) ---> number
Example:
Load "stdlib.ring"
Puts("Test Gcd()")
see gcd (24, 32) + nl
47.29 LCM() function
Compute the least common multiple of two integers.
Syntax:
lcm(number,number) ---> number
Example:
Load "stdlib.ring"
Puts("Test Lcm()")
see Lcm(24,36) + nl
47.30 SumList() function
Compute the sum of a list of integers.
Syntax:
sumlist(list) ---> number
Example:
Load "stdlib.ring"
Puts("Test Sumlist()")
47.28. GCD() function 389
Ring Documentation, Release 1.9
aList = [1,2,3,4,5]
see Sumlist(aList) + nl
47.31 ProdList() function
Compute the product of a list of integers.
Syntax:
prodlist(list) ---> number
Example:
Load "stdlib.ring"
Puts("Test Prodlist()")
aList = [1,2,3,4,5]
see Prodlist(aList) + nl
47.32 EvenOrOdd() function
Test whether an integer is even or odd.
Result of test (1=odd 2=even).
Syntax:
evenorodd(number) ---> 1 (odd) or 2 (even)
Example:
Load "stdlib.ring"
Puts("Test Evenorodd()")
nr = 17
see Evenorodd(nr) + nl
47.33 Factors() function
Compute the factors of a positive integer.
Syntax:
factors(number) ---> list
Example:
Load "stdlib.ring"
Puts("Test Factors()")
n = 45
aList = factors(n)
see "Factors of " + n + " = "
for i = 1 to len(aList)
47.31. ProdList() function 390
Ring Documentation, Release 1.9
see "" + aList[i] + " "
next
47.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)
47.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
47.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)
47.34. Palindrome() function 391
Ring Documentation, Release 1.9
47.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)
47.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)
47.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
47.37. MatrixMulti() function 392
Ring Documentation, Release 1.9
47.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
47.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)
47.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.
47.40. Permutation() function 393
Ring Documentation, Release 1.9
Puts("Test Substring()")
a = "abcxyzqweabc"
b = "abc"
i = 4
see substring(a,b,i)
47.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
47.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
47.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
47.43. ChangeString() function 394
Ring Documentation, Release 1.9
47.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") )
47.47 MakeDir() function
Make Directory
Syntax:
MakeDir(String)
Example:
Load "stdlib.ring"
# Create Directory
puts("create Directory : myfolder")
makedir("myfolder")
47.48 Fsize() function
The function return the file size in bytes.
Syntax:
FSize(File Handle) ---> Number (File Size in Bytes)
47.49 TrimAll() function
Remove all spaces and tabs characters from a string
Syntax:
TrimAll(cString) ---> cString # Without Spaces and Tabs
47.46. DirExists() function 395
Ring Documentation, Release 1.9
47.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
47.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
47.52 EpochTime() function
Return the Epoch Time
Syntax:
EpochTime(cDate,cTime) ---> nEpochTime
Example:
see EpochTime( Date(), Time() )
47.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
47.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:
47.50. TrimLeft() function 396
Ring Documentation, Release 1.9
aList = ListAllFiles("c:/ring/ringlibs","ring") # *.ring only
aList = sort(aList)
see aList
Example:
see listallfiles("b:/ring/ringlibs/weblib","") # All Files
47.55 SystemSilent() Function
We can execute system commands using the SystemSilent() function to avoid displaying the output!
Syntax:
SystemSilent(cCommand)
47.56 OSCreateOpenFolder() Function
Create folder then change the current folder to this new folder
Syntax:
OSCreateOpenFolder(cCommand)
47.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")
47.58 OSDeleteFolder() Function
Delete Folder in the current Directory
Syntax:
OSDeleteFolder(cFolderName)
47.55. SystemSilent() Function 397
Ring Documentation, Release 1.9
47.59 OSCopyFile() Function
Copy File to the current directory
Syntax:
OSCopyFile(cFileName)
47.60 OSDeleteFile() Function
Delete File
Syntax:
OSDeleteFile(cFileName)
47.61 OSRenameFile() Function
Rename File
Syntax:
OSRenameFile(cOldFileName,cNewFileName)
47.62 List2Code() Function
This function covert a Ring list during the runtime to Ring source code that we can save to source files.
The list may contains strings, numbers or sub lists.
Example:
load "stdlibcore.ring"
aList = 1:10
? list2Code(aList)
Output:
[
1,2,3,4,5,6,7,8,9,10
]
47.63 Str2ASCIIList()
Convert a string of bytes to a list of numbers where each item represent the ASCII code of one byte in the string.
Syntax:
Str2ASCIIList(String) ---> List of numbers
47.59. OSCopyFile() Function 398

More Related Content

PDF
The Ring programming language version 1.5.2 book - Part 34 of 181
PDF
The Ring programming language version 1.8 book - Part 40 of 202
PDF
The Ring programming language version 1.7 book - Part 38 of 196
PDF
The Ring programming language version 1.5.1 book - Part 32 of 180
PDF
The Ring programming language version 1.9 book - Part 33 of 210
PDF
The Ring programming language version 1.8 book - Part 30 of 202
PDF
The Ring programming language version 1.4.1 book - Part 3 of 31
PDF
The Ring programming language version 1.6 book - Part 27 of 189
The Ring programming language version 1.5.2 book - Part 34 of 181
The Ring programming language version 1.8 book - Part 40 of 202
The Ring programming language version 1.7 book - Part 38 of 196
The Ring programming language version 1.5.1 book - Part 32 of 180
The Ring programming language version 1.9 book - Part 33 of 210
The Ring programming language version 1.8 book - Part 30 of 202
The Ring programming language version 1.4.1 book - Part 3 of 31
The Ring programming language version 1.6 book - Part 27 of 189

What's hot (20)

PPT
JDK1.7 features
PDF
The Ring programming language version 1.3 book - Part 50 of 88
PDF
The Ring programming language version 1.10 book - Part 45 of 212
PDF
The Ring programming language version 1.10 book - Part 34 of 212
PDF
The Ring programming language version 1.5.3 book - Part 77 of 184
PDF
The Ring programming language version 1.5.4 book - Part 26 of 185
PDF
The Ring programming language version 1.5.2 book - Part 13 of 181
PDF
The Ring programming language version 1.5.1 book - Part 12 of 180
PDF
AJUG April 2011 Cascading example
PDF
The Ring programming language version 1.4 book - Part 18 of 30
PDF
The Ring programming language version 1.4.1 book - Part 7 of 31
PDF
The Ring programming language version 1.9 book - Part 90 of 210
DOCX
Spark_Documentation_Template1
PDF
PyCon KR 2019 sprint - RustPython by example
PDF
The Ring programming language version 1.2 book - Part 24 of 84
PDF
The Ring programming language version 1.5.3 book - Part 26 of 184
PPTX
Joker 2015 - Валеев Тагир - Что же мы измеряем?
PDF
Phil Bartie QGIS PLPython
PDF
Transducers in JavaScript
PDF
The Ring programming language version 1.9 book - Part 32 of 210
JDK1.7 features
The Ring programming language version 1.3 book - Part 50 of 88
The Ring programming language version 1.10 book - Part 45 of 212
The Ring programming language version 1.10 book - Part 34 of 212
The Ring programming language version 1.5.3 book - Part 77 of 184
The Ring programming language version 1.5.4 book - Part 26 of 185
The Ring programming language version 1.5.2 book - Part 13 of 181
The Ring programming language version 1.5.1 book - Part 12 of 180
AJUG April 2011 Cascading example
The Ring programming language version 1.4 book - Part 18 of 30
The Ring programming language version 1.4.1 book - Part 7 of 31
The Ring programming language version 1.9 book - Part 90 of 210
Spark_Documentation_Template1
PyCon KR 2019 sprint - RustPython by example
The Ring programming language version 1.2 book - Part 24 of 84
The Ring programming language version 1.5.3 book - Part 26 of 184
Joker 2015 - Валеев Тагир - Что же мы измеряем?
Phil Bartie QGIS PLPython
Transducers in JavaScript
The Ring programming language version 1.9 book - Part 32 of 210
Ad

Similar to The Ring programming language version 1.9 book - Part 43 of 210 (20)

PDF
The Ring programming language version 1.5.1 book - Part 33 of 180
PDF
The Ring programming language version 1.6 book - Part 37 of 189
PDF
The Ring programming language version 1.10 book - Part 44 of 212
PDF
The Ring programming language version 1.5.4 book - Part 35 of 185
PDF
The Ring programming language version 1.5.4 book - Part 34 of 185
PDF
The Ring programming language version 1.9 book - Part 42 of 210
PDF
The Ring programming language version 1.5.3 book - Part 34 of 184
PDF
The Ring programming language version 1.6 book - Part 36 of 189
PDF
The Ring programming language version 1.3 book - Part 25 of 88
PDF
The Ring programming language version 1.5.2 book - Part 33 of 181
PDF
The Ring programming language version 1.2 book - Part 23 of 84
PDF
The Ring programming language version 1.8 book - Part 39 of 202
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.1 book - Part 35 of 180
PDF
The Ring programming language version 1.8 book - Part 29 of 202
PDF
The Ring programming language version 1.4 book - Part 6 of 30
PDF
The Ring programming language version 1.9 book - Part 31 of 210
PDF
The Ring programming language version 1.6 book - Part 26 of 189
PDF
The Ring programming language version 1.5.3 book - Part 24 of 184
The Ring programming language version 1.5.1 book - Part 33 of 180
The Ring programming language version 1.6 book - Part 37 of 189
The Ring programming language version 1.10 book - Part 44 of 212
The Ring programming language version 1.5.4 book - Part 35 of 185
The Ring programming language version 1.5.4 book - Part 34 of 185
The Ring programming language version 1.9 book - Part 42 of 210
The Ring programming language version 1.5.3 book - Part 34 of 184
The Ring programming language version 1.6 book - Part 36 of 189
The Ring programming language version 1.3 book - Part 25 of 88
The Ring programming language version 1.5.2 book - Part 33 of 181
The Ring programming language version 1.2 book - Part 23 of 84
The Ring programming language version 1.8 book - Part 39 of 202
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.1 book - Part 35 of 180
The Ring programming language version 1.8 book - Part 29 of 202
The Ring programming language version 1.4 book - Part 6 of 30
The Ring programming language version 1.9 book - Part 31 of 210
The Ring programming language version 1.6 book - Part 26 of 189
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)

PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
System and Network Administration Chapter 2
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PPTX
ai tools demonstartion for schools and inter college
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PPTX
Transform Your Business with a Software ERP System
PDF
Nekopoi APK 2025 free lastest update
PDF
Digital Strategies for Manufacturing Companies
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PPTX
Essential Infomation Tech presentation.pptx
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
medical staffing services at VALiNTRY
PPTX
Odoo POS Development Services by CandidRoot Solutions
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
System and Network Administration Chapter 2
Operating system designcfffgfgggggggvggggggggg
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
ai tools demonstartion for schools and inter college
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Transform Your Business with a Software ERP System
Nekopoi APK 2025 free lastest update
Digital Strategies for Manufacturing Companies
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Upgrade and Innovation Strategies for SAP ERP Customers
Essential Infomation Tech presentation.pptx
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Design an Analysis of Algorithms I-SECS-1021-03
medical staffing services at VALiNTRY
Odoo POS Development Services by CandidRoot Solutions

The Ring programming language version 1.9 book - Part 43 of 210

  • 1. Ring Documentation, Release 1.9 Syntax: Endswith(string, substring) ---> True/False Example: Load "stdlib.ring" Puts("Test Endswith()") see endsWith("CalmoSoft", "Soft") + nl 47.28 GCD() function Finding of the greatest common divisor of two integers. Syntax: Gcd(number,number) ---> number Example: Load "stdlib.ring" Puts("Test Gcd()") see gcd (24, 32) + nl 47.29 LCM() function Compute the least common multiple of two integers. Syntax: lcm(number,number) ---> number Example: Load "stdlib.ring" Puts("Test Lcm()") see Lcm(24,36) + nl 47.30 SumList() function Compute the sum of a list of integers. Syntax: sumlist(list) ---> number Example: Load "stdlib.ring" Puts("Test Sumlist()") 47.28. GCD() function 389
  • 2. Ring Documentation, Release 1.9 aList = [1,2,3,4,5] see Sumlist(aList) + nl 47.31 ProdList() function Compute the product of a list of integers. Syntax: prodlist(list) ---> number Example: Load "stdlib.ring" Puts("Test Prodlist()") aList = [1,2,3,4,5] see Prodlist(aList) + nl 47.32 EvenOrOdd() function Test whether an integer is even or odd. Result of test (1=odd 2=even). Syntax: evenorodd(number) ---> 1 (odd) or 2 (even) Example: Load "stdlib.ring" Puts("Test Evenorodd()") nr = 17 see Evenorodd(nr) + nl 47.33 Factors() function Compute the factors of a positive integer. Syntax: factors(number) ---> list Example: Load "stdlib.ring" Puts("Test Factors()") n = 45 aList = factors(n) see "Factors of " + n + " = " for i = 1 to len(aList) 47.31. ProdList() function 390
  • 3. Ring Documentation, Release 1.9 see "" + aList[i] + " " next 47.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) 47.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 47.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) 47.34. Palindrome() function 391
  • 4. Ring Documentation, Release 1.9 47.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) 47.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) 47.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 47.37. MatrixMulti() function 392
  • 5. Ring Documentation, Release 1.9 47.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 47.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) 47.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. 47.40. Permutation() function 393
  • 6. Ring Documentation, Release 1.9 Puts("Test Substring()") a = "abcxyzqweabc" b = "abc" i = 4 see substring(a,b,i) 47.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 47.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 47.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 47.43. ChangeString() function 394
  • 7. Ring Documentation, Release 1.9 47.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") ) 47.47 MakeDir() function Make Directory Syntax: MakeDir(String) Example: Load "stdlib.ring" # Create Directory puts("create Directory : myfolder") makedir("myfolder") 47.48 Fsize() function The function return the file size in bytes. Syntax: FSize(File Handle) ---> Number (File Size in Bytes) 47.49 TrimAll() function Remove all spaces and tabs characters from a string Syntax: TrimAll(cString) ---> cString # Without Spaces and Tabs 47.46. DirExists() function 395
  • 8. Ring Documentation, Release 1.9 47.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 47.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 47.52 EpochTime() function Return the Epoch Time Syntax: EpochTime(cDate,cTime) ---> nEpochTime Example: see EpochTime( Date(), Time() ) 47.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 47.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: 47.50. TrimLeft() function 396
  • 9. Ring Documentation, Release 1.9 aList = ListAllFiles("c:/ring/ringlibs","ring") # *.ring only aList = sort(aList) see aList Example: see listallfiles("b:/ring/ringlibs/weblib","") # All Files 47.55 SystemSilent() Function We can execute system commands using the SystemSilent() function to avoid displaying the output! Syntax: SystemSilent(cCommand) 47.56 OSCreateOpenFolder() Function Create folder then change the current folder to this new folder Syntax: OSCreateOpenFolder(cCommand) 47.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") 47.58 OSDeleteFolder() Function Delete Folder in the current Directory Syntax: OSDeleteFolder(cFolderName) 47.55. SystemSilent() Function 397
  • 10. Ring Documentation, Release 1.9 47.59 OSCopyFile() Function Copy File to the current directory Syntax: OSCopyFile(cFileName) 47.60 OSDeleteFile() Function Delete File Syntax: OSDeleteFile(cFileName) 47.61 OSRenameFile() Function Rename File Syntax: OSRenameFile(cOldFileName,cNewFileName) 47.62 List2Code() Function This function covert a Ring list during the runtime to Ring source code that we can save to source files. The list may contains strings, numbers or sub lists. Example: load "stdlibcore.ring" aList = 1:10 ? list2Code(aList) Output: [ 1,2,3,4,5,6,7,8,9,10 ] 47.63 Str2ASCIIList() Convert a string of bytes to a list of numbers where each item represent the ASCII code of one byte in the string. Syntax: Str2ASCIIList(String) ---> List of numbers 47.59. OSCopyFile() Function 398