SlideShare a Scribd company logo
Ring Documentation, Release 1.2
22.10 Substr() Function
We can work on sub strings inside a string using the substr() function. Using Substr() we can
• Find substring
• Get substring from position to end
• Get Number of characters from position
• Transform Substring To Another Substring
22.11 Find substring
Syntax:
substr(string,substring) ---> the starting position of substring in string
Example:
cStr = "Welcome to the Ring programming language"
see substr(cStr,"Ring") # print 16
22.12 Get substring from position to end
Syntax:
substr(string,position) ---> Get substring starting from position to end
Example:
cStr = "Welcome to the Ring programming language"
nPos = substr(cStr,"Ring") # nPos = 16
see substr(cStr,nPos) # print Ring programming language
22.13 Get Number of Characters From Position
Syntax:
substr(string,position,count) ---> Get characters starting from position
Example:
cStr = "Welcome to the Ring programming language"
nPos = substr(cStr,"Ring") # nPos = 16
see substr(cStr,nPos,4) # print Ring
22.14 Transform Substring To Another Substring
Syntax:
22.10. Substr() Function 100
Ring Documentation, Release 1.2
substr(string,substring,newsubstring) ---> Transformed string (Match case)
substr(string,substring,newsubstring,1) ---> Transformed string (Ignore case)
Example:
cStr = "Welcome to the New programming language"
see substr(cStr,"New","Ring") + nl # print Welcome to the Ring programming language
see substr(cStr,"new","Ring",1)+ nl # print Welcome to the Ring programming language
22.15 strcmp() Function
We can compare between two strings using the strcmp() function.
Syntax:
strcmp(cString1,cString2) ---> value = 0 if cString1 = cString2
value < 0 if cString1 < cString2
value > 0 if cString1 > cString2
Example:
see strcmp("hello","hello") + nl +
strcmp("abc","bcd") + nl +
strcmp("bcd","abc") + nl
Output:
0
-1
1
22.16 str2list() and list2str() Functions
We can convert string lines to list items using the str2list() function. Also we can convert the list to a string using
list2str() function.
Syntax:
str2list(string) ---> list contains the string lines
list2str(list) ---> string contains the list items
Example:
/* output:
** Items : 4
** Item : Hello
** Item : How are you ?
** Item : are you fine ?
** Item : ok
** list2Str result = Hello
** How are you ?
** are you fine ?
** ok
** Done
*/
22.15. strcmp() Function 101
Ring Documentation, Release 1.2
mystr = "Hello
How are you ?
are you fine ?
ok"
mylist = str2list(mystr)
see "Items : " + len(mylist) + nl
for x in mylist
see "Item : " + x + nl
next
newstr = list2str(mylist)
see "list2Str result = " + newstr
if mystr = newstr
see nl + "Done"
else
see nl + "Error!"
ok
22.16. str2list() and list2str() Functions 102
CHAPTER
TWENTYTHREE
DATE AND TIME
In this chapter we are going to learn about the date and time functions.
23.1 Clock() Function
Syntax:
Clock() ---> The number of clock ticks from program start
Example:
See "Calculate performance" + nl
t1 = clock()
for x = 1 to 1000000 next
see clock() - t1
23.2 ClocksPerSecond() Function
Return how many clocks in one second
Syntax:
clockspersecond() ---> Number of clocks in one second
Example:
# Wait 1 second
t = clock()
while clock() - t <= clockspersecond() end
23.3 Time() Function
We can get the system time using the Time() function.
Example:
See "Time : " + time()
103
Ring Documentation, Release 1.2
23.4 Date() Function
We can get the date using the Date() function.
Syntax:
Date() ---> String represent the date "dd/mm/yyyy"
Example:
See "Date : " + date() # Date : 24/05/2015
23.5 TimeList() Function
We can print the date and the time information using the TimeList() function.
Syntax:
TimeList() ---> List contains the time and date information.
The next table presents the list items
index value
1 abbreviated weekday name
2 full weekday name
3 abbreviated month name
4 full month name
5 Date & Time
6 Day of the month
7 Hour (24)
8 Hour (12)
9 Day of the year
10 Month of the year
11 Minutes after hour
12 AM or PM
13 Seconds after the hour
14 Week of the year (sun-sat)
15 day of the week
16 date
17 time
18 year of the century
19 year
20 time zone
21 percent sign
Example:
/* Output:
** Sun abbreviated weekday name
** Sunday full weekday name
** May abbreviated month name
** May full month name
** 05/24/15 09:58:38 Date & Time
** 24 Day of the month
** 09 Hour (24)
23.4. Date() Function 104
Ring Documentation, Release 1.2
** 09 Hour (12)
** 144 Day of the year
** 05 Month of the year
** 58 Minutes after hour
** AM AM or PM
** 38 Seconds after the hour
** 21 Week of the year (sun-sat)
** 0 day of the week
** 05/24/15 date
** 09:58:38 time
** 15 year of the century
** 2015 year
** Arab Standard Time time zone
** % percent sign
*/
See TimeList()
Example:
See "Day Name : " + TimeList()[2] # Sunday
Example:
See "Month Name : " + TimeList()[4] # May
23.6 AddDays() Function
Syntax:
AddDays(cDate,nDays) ---> Date from cDate and after nDays
Example:
cDate = date()
see cDate + nl # 24/05/2015
cDate = adddays(cDate,10)
see cDate + nl # 03/06/2015
23.7 DiffDays() Function
Syntax:
DiffDays(cDate1,cDate2) ---> number of days (Date1 - Date2)
Example:
cDate1 = date()
see cDate1 + nl # 24/05/2015
cDate2 = adddays(cDate1,10)
see cDate2 + nl # 03/06/2015
see "DiffDays = " + diffdays(cDate1,cDate2) + nl # -10
see "DiffDays = " + diffdays(cDate2,cDate1) + nl # 10
23.6. AddDays() Function 105
CHAPTER
TWENTYFOUR
CHECK DATA TYPE AND CONVERSION
In this chapter we are going to learn about the functions that can be used for
• Checking Data Type
• Checking Character
• Conversion
24.1 Check Data Type
The next functions can be used to check the data type
• isstring()
• isnumber()
• islist()
• type()
• isnull()
24.2 IsString() Function
Using the IsString() function we can know if the value is a string or not
Syntax:
IsString(value) ---> 1 if the value is a string or 0 if not
Example:
see isstring(5) + nl + # print 0
isstring("hello") + nl # print 1
24.3 IsNumber() Function
Using the IsNumber() function we can know if the value is a number or not
Syntax:
106
Ring Documentation, Release 1.2
IsNumber(value) ---> 1 if the value is a number or 0 if not
Example:
see isnumber(5) + nl + # print 1
isnumber("hello") + nl # print 0
24.4 IsList() Function
Using the IsList() function we can know if the value is a list or not
Syntax:
IsList(value) ---> 1 if the value is a list or 0 if not
Example:
see islist(5) + nl + # print 0
islist("hello") + nl + # print 0
islist([1,3,5]) # print 1
24.5 Type() Function
We can know the type of a value using the Type() Function.
Syntax:
Type(value) ---> The Type as String
Example:
see Type(5) + nl + # print NUMBER
Type("hello") + nl + # print STRING
Type([1,3,5]) # print LIST
24.6 IsNULL() Function
We can check the value to know if it’s null or not using the IsNULL() function
Syntax:
IsNULL(value) ---> 1 if the value is NULL or 0 if not
Example:
see isnull(5) + nl + # print 0
isnull("hello") + nl + # print 0
isnull([1,3,5]) + nl + # print 0
isnull("") + nl + # print 1
isnull("NULL") # print 1
24.4. IsList() Function 107
Ring Documentation, Release 1.2
24.7 Check Character
The next functions can be used to check character
• isalnum()
• isalpha()
• iscntrl()
• isdigit()
• isgraph()
• islower()
• isprint()
• ispunct()
• isspace()
• isupper()
• isxdigit()
24.8 IsAlNum() Function
We can test a character or a string using the IsAlNum() Function
Syntax:
IsAlNum(value) ---> 1 if the value is digit/letter or 0 if not
Example:
see isalnum("Hello") + nl + # print 1
isalnum("123456") + nl + # print 1
isalnum("ABCabc123") + nl + # print 1
isalnum("How are you") # print 0 because of spaces
24.9 IsAlpha() Function
We can test a character or a string using the IsAlpha() Function
Syntax:
IsAlpha(value) ---> 1 if the value is a letter or 0 if not
Example:
see isalpha("Hello") + nl + # print 1
isalpha("123456") + nl + # print 0
isalpha("ABCabc123") + nl + # print 0
isalpha("How are you") # print 0
24.7. Check Character 108
Ring Documentation, Release 1.2
24.10 IsCntrl() Function
We can test a character or a string using the IsCntrl() Function
Syntax:
IsCntrl(value) ---> 1 if the value is a control character (no printing position) or 0 if not
Example:
See iscntrl("hello") + nl + # print 0
iscntrl(nl) # print 1
24.11 IsDigit() Function
We can test a character or a string using the IsDigit() Function
Syntax:
IsDigit(value) ---> 1 if the value is a digit or 0 if not
Example:
see isdigit("0123456789") + nl + # print 1
isdigit("0123a") # print 0
24.12 IsGraph() Function
We can test a character or a string using the IsGraph() Function
Syntax:
IsGraph(value) ---> 1 if the value can be printed (Except space) or 0 if not
Example:
see isgraph("abcdef") + nl + # print 1
isgraph("abc def") # print 0
24.13 IsLower() Function
We can test a character or a string using the IsLower() Function
Syntax:
IsLower(value) ---> 1 if the value is lowercase letter or 0 if not
Example:
see islower("abcDEF") + nl + # print 0
islower("ghi") # print 1
24.10. IsCntrl() Function 109

More Related Content

What's hot (20)

PDF
The Ring programming language version 1.10 book - Part 31 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.6 book - Part 183 of 189
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.3 book - Part 12 of 88
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.3 book - Part 20 of 184
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.2 book - Part 19 of 181
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.4.1 book - Part 6 of 31
Mahmoud Samir Fayed
 
PDF
Pivorak Clojure by Dmytro Bignyak
Pivorak MeetUp
 
PDF
The Ring programming language version 1.7 book - Part 23 of 196
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.2 book - Part 26 of 181
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.6 book - Part 26 of 189
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.3 book - Part 24 of 184
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.4 book - Part 20 of 185
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.4 book - Part 27 of 185
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.4 book - Part 25 of 185
Mahmoud Samir Fayed
 
PDF
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
kinan keshkeh
 
PDF
The Ring programming language version 1.6 book - Part 44 of 189
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.3 book - Part 32 of 88
Mahmoud Samir Fayed
 
DOC
BingoConsoleApp
Imtiazur Syed
 
PDF
The Ring programming language version 1.4.1 book - Part 3 of 31
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.3 book - Part 25 of 184
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 31 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.6 book - Part 183 of 189
Mahmoud Samir Fayed
 
The Ring programming language version 1.3 book - Part 12 of 88
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.3 book - Part 20 of 184
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.2 book - Part 19 of 181
Mahmoud Samir Fayed
 
The Ring programming language version 1.4.1 book - Part 6 of 31
Mahmoud Samir Fayed
 
Pivorak Clojure by Dmytro Bignyak
Pivorak MeetUp
 
The Ring programming language version 1.7 book - Part 23 of 196
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.2 book - Part 26 of 181
Mahmoud Samir Fayed
 
The Ring programming language version 1.6 book - Part 26 of 189
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.3 book - Part 24 of 184
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.4 book - Part 20 of 185
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.4 book - Part 27 of 185
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.4 book - Part 25 of 185
Mahmoud Samir Fayed
 
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
kinan keshkeh
 
The Ring programming language version 1.6 book - Part 44 of 189
Mahmoud Samir Fayed
 
The Ring programming language version 1.3 book - Part 32 of 88
Mahmoud Samir Fayed
 
BingoConsoleApp
Imtiazur Syed
 
The Ring programming language version 1.4.1 book - Part 3 of 31
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.3 book - Part 25 of 184
Mahmoud Samir Fayed
 

Viewers also liked (20)

PDF
The Ring programming language version 1.2 book - Part 27 of 84
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.2 book - Part 14 of 84
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.2 book - Part 36 of 84
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.2 book - Part 38 of 84
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.2 book - Part 29 of 84
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.2 book - Part 28 of 84
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.2 book - Part 32 of 84
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.2 book - Part 30 of 84
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.2 book - Part 35 of 84
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.2 book - Part 39 of 84
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.2 book - Part 46 of 84
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.2 book - Part 48 of 84
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.2 book - Part 31 of 84
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.2 book - Part 26 of 84
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.2 book - Part 11 of 84
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.2 book - Part 12 of 84
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.2 book - Part 10 of 84
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.2 book - Part 7 of 84
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.2 book - Part 9 of 84
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.2 book - Part 43 of 84
Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 27 of 84
Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 14 of 84
Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 36 of 84
Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 38 of 84
Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 29 of 84
Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 28 of 84
Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 32 of 84
Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 30 of 84
Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 35 of 84
Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 39 of 84
Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 46 of 84
Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 48 of 84
Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 31 of 84
Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 26 of 84
Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 11 of 84
Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 12 of 84
Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 10 of 84
Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 7 of 84
Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 9 of 84
Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 43 of 84
Mahmoud Samir Fayed
 
Ad

Similar to The Ring programming language version 1.2 book - Part 13 of 84 (20)

PDF
The Ring programming language version 1.7 book - Part 27 of 196
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.1 book - Part 22 of 180
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.4 book - Part 6 of 30
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.4 book - Part 24 of 185
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.2 book - Part 23 of 181
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 32 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.9 book - Part 30 of 210
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.8 book - Part 28 of 202
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.3 book - Part 23 of 184
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.4 book - Part 5 of 30
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.7 book - Part 28 of 196
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.8 book - Part 94 of 202
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.3 book - Part 14 of 88
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.2 book - Part 24 of 181
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.4 book - Part 29 of 30
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.9 book - Part 32 of 210
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.2 book - Part 16 of 84
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.1 book - Part 21 of 180
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 22 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.2 book - Part 22 of 181
Mahmoud Samir Fayed
 
The Ring programming language version 1.7 book - Part 27 of 196
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.1 book - Part 22 of 180
Mahmoud Samir Fayed
 
The Ring programming language version 1.4 book - Part 6 of 30
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.4 book - Part 24 of 185
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.2 book - Part 23 of 181
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 32 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.9 book - Part 30 of 210
Mahmoud Samir Fayed
 
The Ring programming language version 1.8 book - Part 28 of 202
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.3 book - Part 23 of 184
Mahmoud Samir Fayed
 
The Ring programming language version 1.4 book - Part 5 of 30
Mahmoud Samir Fayed
 
The Ring programming language version 1.7 book - Part 28 of 196
Mahmoud Samir Fayed
 
The Ring programming language version 1.8 book - Part 94 of 202
Mahmoud Samir Fayed
 
The Ring programming language version 1.3 book - Part 14 of 88
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.2 book - Part 24 of 181
Mahmoud Samir Fayed
 
The Ring programming language version 1.4 book - Part 29 of 30
Mahmoud Samir Fayed
 
The Ring programming language version 1.9 book - Part 32 of 210
Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 16 of 84
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.1 book - Part 21 of 180
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 22 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.2 book - Part 22 of 181
Mahmoud Samir Fayed
 
Ad

More from Mahmoud Samir Fayed (20)

PDF
The Ring programming language version 1.10 book - Part 212 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 211 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 210 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 208 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 207 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 205 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 206 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 204 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 203 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 202 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 201 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 200 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 199 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 198 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 197 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 196 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 195 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 194 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 193 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 192 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 212 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 211 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 210 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 208 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 207 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 205 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 206 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 204 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 203 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 202 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 201 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 200 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 199 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 198 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 197 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 196 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 195 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 194 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 193 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 192 of 212
Mahmoud Samir Fayed
 

Recently uploaded (20)

PDF
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
PPTX
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
PPTX
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
PDF
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
PPTX
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
PDF
Unlock Efficiency with Insurance Policy Administration Systems
Insurance Tech Services
 
PDF
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
PDF
Download Canva Pro 2025 PC Crack Full Latest Version
bashirkhan333g
 
PPTX
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
PDF
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
PDF
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
PDF
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
PPTX
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
PDF
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
PDF
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
PPTX
Migrating Millions of Users with Debezium, Apache Kafka, and an Acyclic Synch...
MD Sayem Ahmed
 
PDF
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
PDF
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
PPTX
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
Unlock Efficiency with Insurance Policy Administration Systems
Insurance Tech Services
 
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
Download Canva Pro 2025 PC Crack Full Latest Version
bashirkhan333g
 
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
Migrating Millions of Users with Debezium, Apache Kafka, and an Acyclic Synch...
MD Sayem Ahmed
 
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 

The Ring programming language version 1.2 book - Part 13 of 84

  • 1. Ring Documentation, Release 1.2 22.10 Substr() Function We can work on sub strings inside a string using the substr() function. Using Substr() we can • Find substring • Get substring from position to end • Get Number of characters from position • Transform Substring To Another Substring 22.11 Find substring Syntax: substr(string,substring) ---> the starting position of substring in string Example: cStr = "Welcome to the Ring programming language" see substr(cStr,"Ring") # print 16 22.12 Get substring from position to end Syntax: substr(string,position) ---> Get substring starting from position to end Example: cStr = "Welcome to the Ring programming language" nPos = substr(cStr,"Ring") # nPos = 16 see substr(cStr,nPos) # print Ring programming language 22.13 Get Number of Characters From Position Syntax: substr(string,position,count) ---> Get characters starting from position Example: cStr = "Welcome to the Ring programming language" nPos = substr(cStr,"Ring") # nPos = 16 see substr(cStr,nPos,4) # print Ring 22.14 Transform Substring To Another Substring Syntax: 22.10. Substr() Function 100
  • 2. Ring Documentation, Release 1.2 substr(string,substring,newsubstring) ---> Transformed string (Match case) substr(string,substring,newsubstring,1) ---> Transformed string (Ignore case) Example: cStr = "Welcome to the New programming language" see substr(cStr,"New","Ring") + nl # print Welcome to the Ring programming language see substr(cStr,"new","Ring",1)+ nl # print Welcome to the Ring programming language 22.15 strcmp() Function We can compare between two strings using the strcmp() function. Syntax: strcmp(cString1,cString2) ---> value = 0 if cString1 = cString2 value < 0 if cString1 < cString2 value > 0 if cString1 > cString2 Example: see strcmp("hello","hello") + nl + strcmp("abc","bcd") + nl + strcmp("bcd","abc") + nl Output: 0 -1 1 22.16 str2list() and list2str() Functions We can convert string lines to list items using the str2list() function. Also we can convert the list to a string using list2str() function. Syntax: str2list(string) ---> list contains the string lines list2str(list) ---> string contains the list items Example: /* output: ** Items : 4 ** Item : Hello ** Item : How are you ? ** Item : are you fine ? ** Item : ok ** list2Str result = Hello ** How are you ? ** are you fine ? ** ok ** Done */ 22.15. strcmp() Function 101
  • 3. Ring Documentation, Release 1.2 mystr = "Hello How are you ? are you fine ? ok" mylist = str2list(mystr) see "Items : " + len(mylist) + nl for x in mylist see "Item : " + x + nl next newstr = list2str(mylist) see "list2Str result = " + newstr if mystr = newstr see nl + "Done" else see nl + "Error!" ok 22.16. str2list() and list2str() Functions 102
  • 4. CHAPTER TWENTYTHREE DATE AND TIME In this chapter we are going to learn about the date and time functions. 23.1 Clock() Function Syntax: Clock() ---> The number of clock ticks from program start Example: See "Calculate performance" + nl t1 = clock() for x = 1 to 1000000 next see clock() - t1 23.2 ClocksPerSecond() Function Return how many clocks in one second Syntax: clockspersecond() ---> Number of clocks in one second Example: # Wait 1 second t = clock() while clock() - t <= clockspersecond() end 23.3 Time() Function We can get the system time using the Time() function. Example: See "Time : " + time() 103
  • 5. Ring Documentation, Release 1.2 23.4 Date() Function We can get the date using the Date() function. Syntax: Date() ---> String represent the date "dd/mm/yyyy" Example: See "Date : " + date() # Date : 24/05/2015 23.5 TimeList() Function We can print the date and the time information using the TimeList() function. Syntax: TimeList() ---> List contains the time and date information. The next table presents the list items index value 1 abbreviated weekday name 2 full weekday name 3 abbreviated month name 4 full month name 5 Date & Time 6 Day of the month 7 Hour (24) 8 Hour (12) 9 Day of the year 10 Month of the year 11 Minutes after hour 12 AM or PM 13 Seconds after the hour 14 Week of the year (sun-sat) 15 day of the week 16 date 17 time 18 year of the century 19 year 20 time zone 21 percent sign Example: /* Output: ** Sun abbreviated weekday name ** Sunday full weekday name ** May abbreviated month name ** May full month name ** 05/24/15 09:58:38 Date & Time ** 24 Day of the month ** 09 Hour (24) 23.4. Date() Function 104
  • 6. Ring Documentation, Release 1.2 ** 09 Hour (12) ** 144 Day of the year ** 05 Month of the year ** 58 Minutes after hour ** AM AM or PM ** 38 Seconds after the hour ** 21 Week of the year (sun-sat) ** 0 day of the week ** 05/24/15 date ** 09:58:38 time ** 15 year of the century ** 2015 year ** Arab Standard Time time zone ** % percent sign */ See TimeList() Example: See "Day Name : " + TimeList()[2] # Sunday Example: See "Month Name : " + TimeList()[4] # May 23.6 AddDays() Function Syntax: AddDays(cDate,nDays) ---> Date from cDate and after nDays Example: cDate = date() see cDate + nl # 24/05/2015 cDate = adddays(cDate,10) see cDate + nl # 03/06/2015 23.7 DiffDays() Function Syntax: DiffDays(cDate1,cDate2) ---> number of days (Date1 - Date2) Example: cDate1 = date() see cDate1 + nl # 24/05/2015 cDate2 = adddays(cDate1,10) see cDate2 + nl # 03/06/2015 see "DiffDays = " + diffdays(cDate1,cDate2) + nl # -10 see "DiffDays = " + diffdays(cDate2,cDate1) + nl # 10 23.6. AddDays() Function 105
  • 7. CHAPTER TWENTYFOUR CHECK DATA TYPE AND CONVERSION In this chapter we are going to learn about the functions that can be used for • Checking Data Type • Checking Character • Conversion 24.1 Check Data Type The next functions can be used to check the data type • isstring() • isnumber() • islist() • type() • isnull() 24.2 IsString() Function Using the IsString() function we can know if the value is a string or not Syntax: IsString(value) ---> 1 if the value is a string or 0 if not Example: see isstring(5) + nl + # print 0 isstring("hello") + nl # print 1 24.3 IsNumber() Function Using the IsNumber() function we can know if the value is a number or not Syntax: 106
  • 8. Ring Documentation, Release 1.2 IsNumber(value) ---> 1 if the value is a number or 0 if not Example: see isnumber(5) + nl + # print 1 isnumber("hello") + nl # print 0 24.4 IsList() Function Using the IsList() function we can know if the value is a list or not Syntax: IsList(value) ---> 1 if the value is a list or 0 if not Example: see islist(5) + nl + # print 0 islist("hello") + nl + # print 0 islist([1,3,5]) # print 1 24.5 Type() Function We can know the type of a value using the Type() Function. Syntax: Type(value) ---> The Type as String Example: see Type(5) + nl + # print NUMBER Type("hello") + nl + # print STRING Type([1,3,5]) # print LIST 24.6 IsNULL() Function We can check the value to know if it’s null or not using the IsNULL() function Syntax: IsNULL(value) ---> 1 if the value is NULL or 0 if not Example: see isnull(5) + nl + # print 0 isnull("hello") + nl + # print 0 isnull([1,3,5]) + nl + # print 0 isnull("") + nl + # print 1 isnull("NULL") # print 1 24.4. IsList() Function 107
  • 9. Ring Documentation, Release 1.2 24.7 Check Character The next functions can be used to check character • isalnum() • isalpha() • iscntrl() • isdigit() • isgraph() • islower() • isprint() • ispunct() • isspace() • isupper() • isxdigit() 24.8 IsAlNum() Function We can test a character or a string using the IsAlNum() Function Syntax: IsAlNum(value) ---> 1 if the value is digit/letter or 0 if not Example: see isalnum("Hello") + nl + # print 1 isalnum("123456") + nl + # print 1 isalnum("ABCabc123") + nl + # print 1 isalnum("How are you") # print 0 because of spaces 24.9 IsAlpha() Function We can test a character or a string using the IsAlpha() Function Syntax: IsAlpha(value) ---> 1 if the value is a letter or 0 if not Example: see isalpha("Hello") + nl + # print 1 isalpha("123456") + nl + # print 0 isalpha("ABCabc123") + nl + # print 0 isalpha("How are you") # print 0 24.7. Check Character 108
  • 10. Ring Documentation, Release 1.2 24.10 IsCntrl() Function We can test a character or a string using the IsCntrl() Function Syntax: IsCntrl(value) ---> 1 if the value is a control character (no printing position) or 0 if not Example: See iscntrl("hello") + nl + # print 0 iscntrl(nl) # print 1 24.11 IsDigit() Function We can test a character or a string using the IsDigit() Function Syntax: IsDigit(value) ---> 1 if the value is a digit or 0 if not Example: see isdigit("0123456789") + nl + # print 1 isdigit("0123a") # print 0 24.12 IsGraph() Function We can test a character or a string using the IsGraph() Function Syntax: IsGraph(value) ---> 1 if the value can be printed (Except space) or 0 if not Example: see isgraph("abcdef") + nl + # print 1 isgraph("abc def") # print 0 24.13 IsLower() Function We can test a character or a string using the IsLower() Function Syntax: IsLower(value) ---> 1 if the value is lowercase letter or 0 if not Example: see islower("abcDEF") + nl + # print 0 islower("ghi") # print 1 24.10. IsCntrl() Function 109