SlideShare a Scribd company logo
Ring Documentation, Release 1.2
12.4 Using Sublime Text 2
Folder : ring/editor/sublime text 2
In the folder Sublime_Text_2 you will find the next three files
1 - ring.json-tmlanguage
2 - ring.sublime-build
3 - ring.tmlanguage
Just Copy the files to the next path
“C:Users{UserName}AppDataRoamingSublime Text 2PackagesUser”
The file ring.sublime-build includes the next line
“cmd”: [”B:ringbinring.exe”,”$file”],
You can modify it according to the ring.exe path in your machine
12.4. Using Sublime Text 2 60
Ring Documentation, Release 1.2
12.5 Using Visual Studio IDE
Folder : ring/editor/visualstudio
Check the ReadMe file for installation instructions.
12.5. Using Visual Studio IDE 61
CHAPTER
THIRTEEN
VARIABLES
To create a new variable, you just need to determine the variable name & value. The value will determine the variable
type and you can change the value to switch between the types using the same variable name.
Syntax:
<Variable Name> = <Value>
Tip: The operator ‘=’ is used here as an Assignment operator and the same operator can be used in conditions, but
for testing equality of expressions.
Note: The Variable will contains the real value (not a reference). This means that once you change the variable value,
the old value will be removed from memory (even if the variable contains a list or object).
13.1 Dynamic Typing
Ring is a dynamic programming language that uses Dynamic Typing.
x = "Hello" # x is a string
see x + nl
x = 5 # x is a number (int)
see x + nl
x = 1.2 # x is a number (double)
see x + nl
x = [1,2,3,4] # x is a list
see x # print list items
x = date() # x is a string contains date
see x + nl
x = time() # x is a string contains time
see x + nl
x = true # x is a number (logical value = 1)
see x + nl
x = false # x is a number (logical value = 0)
see x + nl
13.2 Deep Copy
We can use the assignment operator ‘=’ to copy variables. We can do that to copy values like strings & numbers. Also,
we can copy complete lists & objects. The assignment operator will do a complete duplication for us. This operation
called Deep Copy
62
Ring Documentation, Release 1.2
list = [1,2,3,"four","five"]
list2 = list
list = []
See list # print the first list - no items to print
See "********" + nl
See list2 # print the second list - contains 5 items
13.3 Weakly Typed
Ring is a weakly typed language, this means that the language can automatically convert between data types (like
string & numbers) when that conversion make sense.
Rules:
<NUMBER> + <STRING> --> <NUMBER>
<STRING> + <NUMBER> --> <STRING>
Note: The same operator ‘+’ can be used as an arithmetic operator or for string concatenation.
Example:
x = 10 # x is a number
y = "20" # y is a string
sum = x + y # sum is a number (y will be converted to a number)
Msg = "Sum = " + sum # Msg is a string (sum will be converted to a string)
see Msg + nl
13.3. Weakly Typed 63
CHAPTER
FOURTEEN
OPERATORS
In this chapter we will introduce the operators provided by the Ring programming langauge.
14.1 Arithmetic Operators
The next table presents all of the arithmetic operators provided by the Ring language. Assume variable X=50 and
variable Y=10 then:
Operator Description Example Result
+ Add x+y 60
- Subtract x-y 40
* Multiplies x*y 500
/ Divide x/y 5
% Modulus x%y 0
++ Increment x++ 51
- - Decrement x- - 49
14.2 Relational Operators
The next table presents all of the relational operators provided by the Ring language. Assume variable X=50 and
variable Y=10 then:
Operator Description Example Result
= Equal x = y False
!= Not Equal x != y True
> Greater than x > y True
< Less than x < y False
>= Greater or Equal x >= y True
<= Less than or Equal x <= y False
14.3 Logical Operators
The next table presents all of the logical operators provided by the Ring language. Assume variable X=True and
variable Y=False then:
Operator Description Example Result
and Logical AND x and y False
or Logical OR x or y True
not Logical Not not x False
64
Ring Documentation, Release 1.2
14.4 Bitwise Operators
The next table presents all of the bitwise operators provided by the Ring language. Assume variable X=8 and variable
Y=2 then:
Operator Description Example Result
& Binary AND x & y 0
| Binary OR x | y 10
^ Binary XOR x ^ y 10
~ Binary Ones Complement ~x -9
<< Binary Left Shift x << y 32
>> Binary Right Shift x >> y 2
14.5 Assignment Operators
The next table presents all of the assignment operators provided by the Ring language.
Assume variable X=8 then:
Operator Description Example Result
= Assignment x = 10 x=10
+= Add AND assignment x += 5 x=13
-= Subtract AND assignment x -= 3 x=5
*= Multiply AND assignment x *= 2 x=16
/= Divide AND assignment x /= 3 x=2.67
%= Modulus AND assignment x %= 2 x=0
<<= Left shift AND assignment x <<= 2 x=32
>>= Right shift AND assignment x >>= 2 x=2
&= Bitwise AND assignment x &= 4 x=0
|= Bitwise OR and assignment x |= 3 x=11
^= Bitwise XOR and assignment x ^= 4 x=12
14.6 Misc Operators
Operator Description
:literal using : before identifier mean literal
Start:End create list contains items from start to end
[list items] define list items
list[index] access list item
obj.name using the dot operator to access object members (attributes/methods).
obj {stmts} execute statements with direct access to object attributes & methods
func(para,...) call function using parameters separated by comma
14.7 Operators Precedence
The next table present operators from higher precedence (Evaluated first) to lower precedence.
14.4. Bitwise Operators 65
Ring Documentation, Release 1.2
Operator
. [] () {}
- ~ :Literal [list items]
++ - -
Start:End
* / %
+ -
<< >>
&
| ^
< > <= >=
= !=
not
and or
Assignment = += -= *= /= %=>>= <<= &= ^= |=
Example:
See 3+5*4 # prints 23
14.7. Operators Precedence 66
CHAPTER
FIFTEEN
CONTROL STRUCTURES - FIRST STYLE
In this chapter we are going to learn about the control structures provided by the Ring programming language.
15.1 Branching
• If Statement
Syntax:
if Expression
Block of statements
but Expression
Block of statements
else
Block of statements
ok
Example:
see "
Main Menu
---------
(1) Say Hello
(2) About
(3) Exit
" give nOption
if nOption = 1 see "Enter your name : " give name see "Hello " + name + nl
but nOption = 2 see "Sample : using if statement" + nl
but nOption = 3 bye
else see "bad option..." + nl
ok
• Switch Statement
Syntax:
switch Expression
on Expression
Block of statements
other
Block of statements
off
67
Ring Documentation, Release 1.2
Example:
See "
Main Menu
---------
(1) Say Hello
(2) About
(3) Exit
" Give nOption
Switch nOption
On 1 See "Enter your name : " Give name See "Hello " + name + nl
On 2 See "Sample : using switch statement" + nl
On 3 Bye
Other See "bad option..." + nl
Off
15.2 Looping
• While Loop
Syntax:
while Expression
Block of statements
end
Example:
While True
See "
Main Menu
---------
(1) Say Hello
(2) About
(3) Exit
" Give nOption
Switch nOption
On 1
See "Enter your name : "
Give name
See "Hello " + name + nl
On 2
See "Sample : using while loop" + nl
On 3
Bye
Other
See "bad option..." + nl
Off
End
• For Loop
Syntax:
15.2. Looping 68
Ring Documentation, Release 1.2
for identifier=expression to expression [step expression]
Block of statements
next
Example:
# print numbers from 1 to 10
for x = 1 to 10 see x + nl next
Example:
# Dynamic loop
See "Start : " give nStart
See "End : " give nEnd
See "Step : " give nStep
For x = nStart to nEnd Step nStep
see x + nl
Next
Example:
# print even numbers from 0 to 10
for x = 0 to 10 step 2
see x + nl
next
Example:
# print even numbers from 10 to 0
for x = 10 to 0 step -2
see x + nl
next
• For in Loop
Syntax:
for identifier in List/String [step expression]
Block of statements
next
Example:
aList = 1:10 # create list contains numbers from 1 to 10
for x in aList see x + nl next # print numbers from 1 to 10
15.3 Using The Step option with For in
We can use the Step option with For in to skip number of items in each iteration
Example:
aList = 1:10 # create list contains numbers from 1 to 10
# print odd items inside the list
for x in aList step 2
see x + nl
next
15.3. Using The Step option with For in 69

More Related Content

What's hot (20)

PDF
The Ring programming language version 1.7 book - Part 22 of 196
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.9 book - Part 27 of 210
Mahmoud Samir Fayed
 
PPTX
Dictionary
Pooja B S
 
PDF
The Ring programming language version 1.5.4 book - Part 19 of 185
Mahmoud Samir Fayed
 
PPTX
Iteration
Pooja B S
 
PPTX
String Manipulation in Python
Pooja B S
 
PDF
The Ring programming language version 1.5.1 book - Part 17 of 180
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.8 book - Part 24 of 202
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 31 of 212
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.10 book - Part 27 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.2 book - Part 31 of 181
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.6 book - Part 22 of 189
Mahmoud Samir Fayed
 
PPTX
Functions & Recursion
Nishant Munjal
 
PDF
The Ring programming language version 1.4.1 book - Part 5 of 31
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.2 book - Part 21 of 84
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.9 book - Part 25 of 210
Mahmoud Samir Fayed
 
PDF
Swift the implicit parts
Maxim Zaks
 
PPTX
Unit2 input output
deepak kumbhar
 
The Ring programming language version 1.7 book - Part 22 of 196
Mahmoud Samir Fayed
 
The Ring programming language version 1.9 book - Part 27 of 210
Mahmoud Samir Fayed
 
Dictionary
Pooja B S
 
The Ring programming language version 1.5.4 book - Part 19 of 185
Mahmoud Samir Fayed
 
Iteration
Pooja B S
 
String Manipulation in Python
Pooja B S
 
The Ring programming language version 1.5.1 book - Part 17 of 180
Mahmoud Samir Fayed
 
The Ring programming language version 1.8 book - Part 24 of 202
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 31 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.4 book - Part 5 of 30
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 27 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.2 book - Part 31 of 181
Mahmoud Samir Fayed
 
The Ring programming language version 1.6 book - Part 22 of 189
Mahmoud Samir Fayed
 
Functions & Recursion
Nishant Munjal
 
The Ring programming language version 1.4.1 book - Part 5 of 31
Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 21 of 84
Mahmoud Samir Fayed
 
The Ring programming language version 1.9 book - Part 25 of 210
Mahmoud Samir Fayed
 
Swift the implicit parts
Maxim Zaks
 
Unit2 input output
deepak kumbhar
 

Viewers also liked (16)

PDF
The Ring programming language version 1.2 book - Part 7 of 84
Mahmoud Samir Fayed
 
PDF
Guillermo Dumrauf - Calculo Financiero Aplicado (Parte 2 de 3)
Fabi frewq
 
PDF
Nk 03 2017_lr_englisch
Zissis Ahladas
 
PDF
The Ring programming language version 1.2 book - Part 8 of 84
Mahmoud Samir Fayed
 
PPTX
Gpl1 8-artikel-tutorial 1
fnfm
 
PDF
Ambientação ADM - dicas de navegação - 1º semestre 2017
Henrique Oliveira
 
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
انصاف کا قتل لوکانہ
maqsood hasni
 
DOCX
Nader Gamal(Mechanical engineer) CV .
Nader Riyad
 
PPT
і.сислюк мат база кабінетів (1)
MARO51
 
PDF
人気プログラム 一覧
ZAC Inc,.
 
PDF
Skhandelwal Portfolio
donydpony
 
DOCX
Resume
Nakul soni
 
PPTX
IoTLT vol24 @ドリコム/汎用機系ひとすじのエンジニアに何が出来るのか?…そしてHULFT IoT紹介/松岡光隆 セゾン情報システムズ
光隆 松岡
 
PPTX
CHAMPSPACE: Living as a Champion (Draft)
Thanakrit Lersmethasakul
 
The Ring programming language version 1.2 book - Part 7 of 84
Mahmoud Samir Fayed
 
Guillermo Dumrauf - Calculo Financiero Aplicado (Parte 2 de 3)
Fabi frewq
 
Nk 03 2017_lr_englisch
Zissis Ahladas
 
The Ring programming language version 1.2 book - Part 8 of 84
Mahmoud Samir Fayed
 
Gpl1 8-artikel-tutorial 1
fnfm
 
Ambientação ADM - dicas de navegação - 1º semestre 2017
Henrique Oliveira
 
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
 
انصاف کا قتل لوکانہ
maqsood hasni
 
Nader Gamal(Mechanical engineer) CV .
Nader Riyad
 
і.сислюк мат база кабінетів (1)
MARO51
 
人気プログラム 一覧
ZAC Inc,.
 
Skhandelwal Portfolio
donydpony
 
Resume
Nakul soni
 
IoTLT vol24 @ドリコム/汎用機系ひとすじのエンジニアに何が出来るのか?…そしてHULFT IoT紹介/松岡光隆 セゾン情報システムズ
光隆 松岡
 
CHAMPSPACE: Living as a Champion (Draft)
Thanakrit Lersmethasakul
 
Ad

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

PDF
The Ring programming language version 1.8 book - Part 23 of 202
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.6 book - Part 21 of 189
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.3 book - Part 19 of 184
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.3 book - Part 18 of 184
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 26 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.4 book - Part 178 of 185
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.2 book - Part 174 of 181
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.9 book - Part 26 of 210
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.8 book - Part 93 of 202
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 7 of 212
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.5.1 book - Part 18 of 180
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.4 book - Part 20 of 185
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.6 book - Part 20 of 189
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.6 book - Part 182 of 189
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.10 book - Part 28 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.6 book - Part 8 of 189
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.1 book - Part 5 of 180
Mahmoud Samir Fayed
 
The Ring programming language version 1.8 book - Part 23 of 202
Mahmoud Samir Fayed
 
The Ring programming language version 1.6 book - Part 21 of 189
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.3 book - Part 19 of 184
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.3 book - Part 18 of 184
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 26 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.4 book - Part 178 of 185
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.2 book - Part 174 of 181
Mahmoud Samir Fayed
 
The Ring programming language version 1.9 book - Part 26 of 210
Mahmoud Samir Fayed
 
The Ring programming language version 1.8 book - Part 93 of 202
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 7 of 212
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.5.1 book - Part 18 of 180
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.4 book - Part 20 of 185
Mahmoud Samir Fayed
 
The Ring programming language version 1.6 book - Part 20 of 189
Mahmoud Samir Fayed
 
The Ring programming language version 1.6 book - Part 182 of 189
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.10 book - Part 28 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.6 book - Part 8 of 189
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.1 book - Part 5 of 180
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)

PPTX
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 
PDF
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
PPTX
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
Download Canva Pro 2025 PC Crack Full Latest Version
bashirkhan333g
 
PDF
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
PPTX
Transforming Mining & Engineering Operations with Odoo ERP | Streamline Proje...
SatishKumar2651
 
PPTX
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
PPTX
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
PDF
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
PPTX
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
PPTX
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
PDF
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
PDF
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
PDF
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
PDF
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
PDF
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
PDF
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
PDF
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
PPTX
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Download Canva Pro 2025 PC Crack Full Latest Version
bashirkhan333g
 
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
Transforming Mining & Engineering Operations with Odoo ERP | Streamline Proje...
SatishKumar2651
 
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 

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

  • 1. Ring Documentation, Release 1.2 12.4 Using Sublime Text 2 Folder : ring/editor/sublime text 2 In the folder Sublime_Text_2 you will find the next three files 1 - ring.json-tmlanguage 2 - ring.sublime-build 3 - ring.tmlanguage Just Copy the files to the next path “C:Users{UserName}AppDataRoamingSublime Text 2PackagesUser” The file ring.sublime-build includes the next line “cmd”: [”B:ringbinring.exe”,”$file”], You can modify it according to the ring.exe path in your machine 12.4. Using Sublime Text 2 60
  • 2. Ring Documentation, Release 1.2 12.5 Using Visual Studio IDE Folder : ring/editor/visualstudio Check the ReadMe file for installation instructions. 12.5. Using Visual Studio IDE 61
  • 3. CHAPTER THIRTEEN VARIABLES To create a new variable, you just need to determine the variable name & value. The value will determine the variable type and you can change the value to switch between the types using the same variable name. Syntax: <Variable Name> = <Value> Tip: The operator ‘=’ is used here as an Assignment operator and the same operator can be used in conditions, but for testing equality of expressions. Note: The Variable will contains the real value (not a reference). This means that once you change the variable value, the old value will be removed from memory (even if the variable contains a list or object). 13.1 Dynamic Typing Ring is a dynamic programming language that uses Dynamic Typing. x = "Hello" # x is a string see x + nl x = 5 # x is a number (int) see x + nl x = 1.2 # x is a number (double) see x + nl x = [1,2,3,4] # x is a list see x # print list items x = date() # x is a string contains date see x + nl x = time() # x is a string contains time see x + nl x = true # x is a number (logical value = 1) see x + nl x = false # x is a number (logical value = 0) see x + nl 13.2 Deep Copy We can use the assignment operator ‘=’ to copy variables. We can do that to copy values like strings & numbers. Also, we can copy complete lists & objects. The assignment operator will do a complete duplication for us. This operation called Deep Copy 62
  • 4. Ring Documentation, Release 1.2 list = [1,2,3,"four","five"] list2 = list list = [] See list # print the first list - no items to print See "********" + nl See list2 # print the second list - contains 5 items 13.3 Weakly Typed Ring is a weakly typed language, this means that the language can automatically convert between data types (like string & numbers) when that conversion make sense. Rules: <NUMBER> + <STRING> --> <NUMBER> <STRING> + <NUMBER> --> <STRING> Note: The same operator ‘+’ can be used as an arithmetic operator or for string concatenation. Example: x = 10 # x is a number y = "20" # y is a string sum = x + y # sum is a number (y will be converted to a number) Msg = "Sum = " + sum # Msg is a string (sum will be converted to a string) see Msg + nl 13.3. Weakly Typed 63
  • 5. CHAPTER FOURTEEN OPERATORS In this chapter we will introduce the operators provided by the Ring programming langauge. 14.1 Arithmetic Operators The next table presents all of the arithmetic operators provided by the Ring language. Assume variable X=50 and variable Y=10 then: Operator Description Example Result + Add x+y 60 - Subtract x-y 40 * Multiplies x*y 500 / Divide x/y 5 % Modulus x%y 0 ++ Increment x++ 51 - - Decrement x- - 49 14.2 Relational Operators The next table presents all of the relational operators provided by the Ring language. Assume variable X=50 and variable Y=10 then: Operator Description Example Result = Equal x = y False != Not Equal x != y True > Greater than x > y True < Less than x < y False >= Greater or Equal x >= y True <= Less than or Equal x <= y False 14.3 Logical Operators The next table presents all of the logical operators provided by the Ring language. Assume variable X=True and variable Y=False then: Operator Description Example Result and Logical AND x and y False or Logical OR x or y True not Logical Not not x False 64
  • 6. Ring Documentation, Release 1.2 14.4 Bitwise Operators The next table presents all of the bitwise operators provided by the Ring language. Assume variable X=8 and variable Y=2 then: Operator Description Example Result & Binary AND x & y 0 | Binary OR x | y 10 ^ Binary XOR x ^ y 10 ~ Binary Ones Complement ~x -9 << Binary Left Shift x << y 32 >> Binary Right Shift x >> y 2 14.5 Assignment Operators The next table presents all of the assignment operators provided by the Ring language. Assume variable X=8 then: Operator Description Example Result = Assignment x = 10 x=10 += Add AND assignment x += 5 x=13 -= Subtract AND assignment x -= 3 x=5 *= Multiply AND assignment x *= 2 x=16 /= Divide AND assignment x /= 3 x=2.67 %= Modulus AND assignment x %= 2 x=0 <<= Left shift AND assignment x <<= 2 x=32 >>= Right shift AND assignment x >>= 2 x=2 &= Bitwise AND assignment x &= 4 x=0 |= Bitwise OR and assignment x |= 3 x=11 ^= Bitwise XOR and assignment x ^= 4 x=12 14.6 Misc Operators Operator Description :literal using : before identifier mean literal Start:End create list contains items from start to end [list items] define list items list[index] access list item obj.name using the dot operator to access object members (attributes/methods). obj {stmts} execute statements with direct access to object attributes & methods func(para,...) call function using parameters separated by comma 14.7 Operators Precedence The next table present operators from higher precedence (Evaluated first) to lower precedence. 14.4. Bitwise Operators 65
  • 7. Ring Documentation, Release 1.2 Operator . [] () {} - ~ :Literal [list items] ++ - - Start:End * / % + - << >> & | ^ < > <= >= = != not and or Assignment = += -= *= /= %=>>= <<= &= ^= |= Example: See 3+5*4 # prints 23 14.7. Operators Precedence 66
  • 8. CHAPTER FIFTEEN CONTROL STRUCTURES - FIRST STYLE In this chapter we are going to learn about the control structures provided by the Ring programming language. 15.1 Branching • If Statement Syntax: if Expression Block of statements but Expression Block of statements else Block of statements ok Example: see " Main Menu --------- (1) Say Hello (2) About (3) Exit " give nOption if nOption = 1 see "Enter your name : " give name see "Hello " + name + nl but nOption = 2 see "Sample : using if statement" + nl but nOption = 3 bye else see "bad option..." + nl ok • Switch Statement Syntax: switch Expression on Expression Block of statements other Block of statements off 67
  • 9. Ring Documentation, Release 1.2 Example: See " Main Menu --------- (1) Say Hello (2) About (3) Exit " Give nOption Switch nOption On 1 See "Enter your name : " Give name See "Hello " + name + nl On 2 See "Sample : using switch statement" + nl On 3 Bye Other See "bad option..." + nl Off 15.2 Looping • While Loop Syntax: while Expression Block of statements end Example: While True See " Main Menu --------- (1) Say Hello (2) About (3) Exit " Give nOption Switch nOption On 1 See "Enter your name : " Give name See "Hello " + name + nl On 2 See "Sample : using while loop" + nl On 3 Bye Other See "bad option..." + nl Off End • For Loop Syntax: 15.2. Looping 68
  • 10. Ring Documentation, Release 1.2 for identifier=expression to expression [step expression] Block of statements next Example: # print numbers from 1 to 10 for x = 1 to 10 see x + nl next Example: # Dynamic loop See "Start : " give nStart See "End : " give nEnd See "Step : " give nStep For x = nStart to nEnd Step nStep see x + nl Next Example: # print even numbers from 0 to 10 for x = 0 to 10 step 2 see x + nl next Example: # print even numbers from 10 to 0 for x = 10 to 0 step -2 see x + nl next • For in Loop Syntax: for identifier in List/String [step expression] Block of statements next Example: aList = 1:10 # create list contains numbers from 1 to 10 for x in aList see x + nl next # print numbers from 1 to 10 15.3 Using The Step option with For in We can use the Step option with For in to skip number of items in each iteration Example: aList = 1:10 # create list contains numbers from 1 to 10 # print odd items inside the list for x in aList step 2 see x + nl next 15.3. Using The Step option with For in 69