Axa Assurance Maroc - Insurer Innovation Award 2024
Ring Docs - Code Editors and Variables
1. Ring Documentation, Release 1.5.3
14.11 The Browser Menu
From this menu we can quickly open common links in the browser
14.12 The Tools Menu
From this window we can run the Form Designer in separate window
Also we can run the REPL (Read-Eval-Print-Loop) application
14.13 The Help Menu
From this menu we can get the help files (CHM & PDF)
14.11. The Browser Menu 145
2. CHAPTER
FIFTEEN
USING OTHER CODE EDITORS
In the Ring/Editor folder you will find extensions for the next editors
• Notepad++
• Geany
• Atom
• Sublime Text 2
• Visual Studio IDE
• Emacs
15.1 Using Notepad++
Folder : ring/editor/notepad_plus_plus
• Open Notepad++
• Open the “Language” menu
• Select “Define your language...”
• Click “Import...”
• select Ring.xml
• Select “OK” on the “Import successful” dialog and close the “User Defined Language” dialog/panel
• You may need to restart notepad++
146
3. Ring Documentation, Release 1.5.3
15.2 Using Geany
Folder : ring/editor/geany
• Run Geany editor
• Click on “Tools -> configuration files -> filetypes_extensions.conf” menu
• Add this line “Ring=*.ring;” without quotes after [Extensions]
• In unbuntu copy file “filetypes.Ring.conf” to folder “/home/USERNAME/filetypes.Ring.conf”
• You can run your files by pressing F5 button
15.2. Using Geany 147
4. Ring Documentation, Release 1.5.3
15.3 Using Atom
Folder : ring/editor/atom
Just Copy the folder atom-language-ring to the next path
"C:Users{UserName}.atomPackages"
15.3. Using Atom 148
5. Ring Documentation, Release 1.5.3
15.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
15.4. Using Sublime Text 2 149
6. Ring Documentation, Release 1.5.3
15.5 Using Visual Studio IDE
Folder : ring/editor/visualstudio
Check the ReadMe file for installation instructions.
15.5. Using Visual Studio IDE 150
7. Ring Documentation, Release 1.5.3
15.6 Using Emacs Editor
Folder : ring/editor/emacs
Check the ReadMe file for installation instructions.
Screen Shot:
15.6. Using Emacs Editor 151
8. CHAPTER
SIXTEEN
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).
16.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
16.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
152
9. Ring Documentation, Release 1.5.3
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
16.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
16.3. Weakly Typed 153
10. CHAPTER
SEVENTEEN
OPERATORS
In this chapter we will introduce the operators provided by the Ring programming langauge.
17.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
17.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
17.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
154