Ring Documentation, Release 1.2
Hit "windows key".
Type "Edit the System environment variables"
Select "Advanced" tab.
Click on "Enviroment Variables..."
Double click on "Path"
Add at the end the new path separated by semicolon.
;C:RingBin
Run Ring Notepad
cd applications/rnote
ring rnote.ring
6.2 Building using Ubuntu Linux
Get the source code
git clone http://github.com/ring-lang/ring.git
Install Libraries
cd ring/src
./installdep.sh
Build Ring (Compiler/VM)
sudo ./buildgcccomplete.sh
Generate RingAllegro Source Code and Build
cd ../extensions/ringallegro
./gencode.sh
./buildgcc.sh
Generate RingLibCurl Source Code and Build
cd ../extensions/ringcurl
./gencode.sh
./buildgcc.sh
Generate RingQt Source Code and Build
cd ../ringqt
./gencode.sh
./buildgcc.sh
To be able to call ring from any folder
cd ../../bin
sudo ./install.sh
Run Ring Notepad
cd applications/rnote
sudo ring rnote.ring
6.2. Building using Ubuntu Linux 40
Ring Documentation, Release 1.2
6.3 Building using MacOS X
Get the source code
git clone http://github.com/ring-lang/ring.git
Install homebrew (follow the directions on homebrew’s homepage). Install Libraries
brew install unixodbc mysql-connector-c allegro openssl homebrew/versions/qt55
brew link --force qt55
Build Ring (Compiler/VM)
cd ring/src
./buildclangcomplete.sh
Generate RingAllegro Source Code and Build
cd ../extensions/ringallegro
./gencode.sh
./buildclang.sh
Generate RingLibCurl Source Code and Build
cd ../extensions/ringcurl
./gencode.sh
./buildclang.sh
Generate RingQt Source Code and Build
cd ../ringqt
./gencode.sh
./buildclang.sh
To be able to call ring from any folder
cd ../../bin
sudo ./install.sh
Run Ring Notepad
cd applications/rnote
sudo ring rnote.ring
6.4 Building using CMake
Install libraries (MySQL Client, OpenSSL, LibCurl, Allegro 5 and Qt 5.5)
cmake .
make
6.3. Building using MacOS X 41
CHAPTER
SEVEN
HOW TO CONTRIBUTE?
Ring is a free-open source project, Everyone is welcome to contribute to Ring.
Project Home : https://github.com/ring-lang/ring
You can help in many parts in the project
• Documentation
• Testing
• Samples
• Applications
• Editors Support
• Libraries in Ring
• Extensions in C/C++
• Compiler and Virtual Machine (VM)
• Ideas and suggestions
7.1 Special thanks to contributors
Throughout the creation of this project, Ring relied heavily on contributions from experts along with college students.
Their input was invaluable, and we want to take a moment to thank them and recognize them for all of their hard work.
Ring Team: http://ring-lang.sf.net/team.html
7.2 Documentation
You can modify anything in the documentation, by updating the text files (*.txt) in this folder : https://github.com/ring-
lang/ring/tree/master/docs/source
The documentation is created using Sphinx : http://www.sphinx-doc.org/en/stable/
7.3 Testing
You can write new tests in this folder
https://github.com/ring-lang/ring/tree/master/tests/scripts
42
Ring Documentation, Release 1.2
7.4 Samples
You can add new samples to this folder
https://github.com/ring-lang/ring/tree/master/samples/other
7.5 Applications
You can add new applications to this folder
https://github.com/ring-lang/ring/tree/master/applications
7.6 Editors Support
You can help in supporting Ring in different code editors
Check the next folder
https://github.com/ring-lang/ring/tree/master/editor
7.7 Libraries in Ring
You can update and add libraries to this folder
https://github.com/ring-lang/ring/tree/master/ringlibs
7.8 Extensions in C/C++
You can add and update extensions in this folder
https://github.com/ring-lang/ring/tree/master/extensions
7.9 Compiler and Virtual Machine (VM)
• Source Code (C Language) : https://github.com/ring-lang/ring/tree/master/src
• Visual Source (PWCT) : https://github.com/ring-lang/ring/tree/master/visualsrc
7.10 Ideas and suggestions
You can share your ideas, suggestions and questions in this group
https://groups.google.com/forum/#!forum/ring-lang
7.4. Samples 43
CHAPTER
EIGHT
GETTING STARTED - FIRST STYLE
8.1 Hello World
The next program prints the Hello World message on the screen (std-out).
see "Hello World"
8.2 Run the program
to run the program, save the code in a file, for example : hello.ring then from the command line or terminal, run it
using the ring interpreter
ring hello.ring
8.3 Not Case-Sensitive
Since the Ring language is not case-sensitive, the same program can be written in different styles
Tip: It’s better to select one style and use it in all of the program source code
SEE "Hello World"
See "Hello World"
8.4 Multi-Line literals
Using Ring we can write multi-line literal, see the next example
See "
Hello
Welcome to the Ring programming language
How are you?
"
Also you can use the nl constant to insert new line and you can use the + operator to concatenate strings
44
Ring Documentation, Release 1.2
Note: nl value means a new line and the actual codes that represent a newline is different between operating systems
See "Hello" + nl + "Welcome to the Ring programming language" +
nl + "How are you?"
8.5 Getting Input
You can get the input from the user using the give command
See "What is your name? "
Give cName
See "Hello " + cName
8.6 No Explicit End For Statements
You don’t need to use ‘;’ or press ENTER to separate statements. The previous program can be written in one line.
See "What is your name? " give cName see "Hello " + cName
8.7 Writing Comments
We can write one line comments and multi-line comments
The comment starts with # or //
Multi-lines comments are written between /* and */
/*
Program Name : My first program using Ring
Date : 2016.09.09
Author : Mahmoud Fayed
*/
See "What is your name? " # print message on screen
give cName # get input from the user
see "Hello " + cName # say hello!
// See "Bye!"
Note: Using // to comment a lines of code is just a code style.
8.5. Getting Input 45
CHAPTER
NINE
GETTING STARTED - SECOND STYLE
9.1 Hello World
The next program prints the Hello World message on the screen (std-out).
put "Hello World"
9.2 Run the program
to run the program, save the code in a file, for example : hello.ring then from the command line or terminal, run it
using the ring interpreter
ring hello.ring
9.3 Not Case-Sensitive
Since the Ring language is not case-sensitive, the same program can be written in different styles
Tip: It’s better to select one style and use it in all of the program source code
PUT "Hello World"
Put "Hello World"
9.4 Multi-Line literals
Using Ring we can write multi-line literal, see the next example
Put "
Hello
Welcome to the Ring programming language
How are you?
"
Also you can use the nl constant to insert new line and you can use the + operator to concatenate strings
46
Ring Documentation, Release 1.2
Note: nl value means a new line and the actual codes that represent a newline is different between operating systems
Put "Hello" + nl + "Welcome to the Ring programming language" +
nl + "How are you?"
9.5 Getting Input
You can get the input from the user using the get command
Put "What is your name? "
Get cName
Put "Hello " + cName
9.6 No Explicit End For Statements
You don’t need to use ‘;’ or press ENTER to separate statements. The previous program can be written in one line.
Put "What is your name? " get cName put "Hello " + cName
9.7 Writing Comments
We can write one line comments and multi-line comments
The comment starts with # or //
Multi-lines comments are written between /* and */
/*
Program Name : My first program using Ring
Date : 2016.09.09
Author : Mahmoud Fayed
*/
Put "What is your name? " # print message on screen
get cName # get input from the user
put "Hello " + cName # say hello!
// Put "Bye!"
Note: Using // to comment a lines of code is just a code style.
9.5. Getting Input 47
CHAPTER
TEN
GETTING STARTED - THIRD STYLE
10.1 Hello World
The next program prints the Hello World message on the screen (std-out).
load "stdlib.ring"
print("Hello World")
10.2 Run the program
to run the program, save the code in a file, for example : hello.ring then from the command line or terminal, run it
using the ring interpreter
ring hello.ring
10.3 Not Case-Sensitive
Since the Ring language is not case-sensitive, the same program can be written in different styles
Tip: It’s better to select one style and use it in all of the program source code
LOAD "stdlib.ring"
PRINT("Hello World")
Load "stdlib.ring"
Print("Hello World")
10.4 Multi-Line literals
Using Ring we can write multi-line literal, see the next example
Load "stdlib.ring"
Print("
Hello
Welcome to the Ring programming language
How are you?
48
Ring Documentation, Release 1.2
")
Also you can use the n to insert new line and you can use #{variable_name} to insert variables values.
Load "stdlib.ring"
Print( "HellonWelcome to the Ring programming languagenHow are you?")
10.5 Getting Input
You can get the input from the user using the getstring() function
Load "stdlib.ring"
Print("What is your name? ")
cName = GetString()
Print("Hello #{cName}")
10.6 No Explicit End For Statements
You don’t need to use ‘;’ or press ENTER to separate statements. The previous program can be written in one line.
Load "stdlib.ring"
Print("What is your name? ") cName=getstring() print("Hello #{cName}")
10.7 Writing Comments
We can write one line comments and multi-line comments
The comment starts with # or //
Multi-lines comments are written between /* and */
/*
Program Name : My first program using Ring
Date : 2016.09.09
Author : Mahmoud Fayed
*/
Load "stdlib.ring"
Print("What is your name? ") # print message on screen
cName=GetString() # get input from the user
print("Hello #{cName}") # say hello!
// print("Bye!")
Note: Using // to comment a lines of code is just a code style.
10.5. Getting Input 49

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

  • 1.
    Ring Documentation, Release1.2 Hit "windows key". Type "Edit the System environment variables" Select "Advanced" tab. Click on "Enviroment Variables..." Double click on "Path" Add at the end the new path separated by semicolon. ;C:RingBin Run Ring Notepad cd applications/rnote ring rnote.ring 6.2 Building using Ubuntu Linux Get the source code git clone http://github.com/ring-lang/ring.git Install Libraries cd ring/src ./installdep.sh Build Ring (Compiler/VM) sudo ./buildgcccomplete.sh Generate RingAllegro Source Code and Build cd ../extensions/ringallegro ./gencode.sh ./buildgcc.sh Generate RingLibCurl Source Code and Build cd ../extensions/ringcurl ./gencode.sh ./buildgcc.sh Generate RingQt Source Code and Build cd ../ringqt ./gencode.sh ./buildgcc.sh To be able to call ring from any folder cd ../../bin sudo ./install.sh Run Ring Notepad cd applications/rnote sudo ring rnote.ring 6.2. Building using Ubuntu Linux 40
  • 2.
    Ring Documentation, Release1.2 6.3 Building using MacOS X Get the source code git clone http://github.com/ring-lang/ring.git Install homebrew (follow the directions on homebrew’s homepage). Install Libraries brew install unixodbc mysql-connector-c allegro openssl homebrew/versions/qt55 brew link --force qt55 Build Ring (Compiler/VM) cd ring/src ./buildclangcomplete.sh Generate RingAllegro Source Code and Build cd ../extensions/ringallegro ./gencode.sh ./buildclang.sh Generate RingLibCurl Source Code and Build cd ../extensions/ringcurl ./gencode.sh ./buildclang.sh Generate RingQt Source Code and Build cd ../ringqt ./gencode.sh ./buildclang.sh To be able to call ring from any folder cd ../../bin sudo ./install.sh Run Ring Notepad cd applications/rnote sudo ring rnote.ring 6.4 Building using CMake Install libraries (MySQL Client, OpenSSL, LibCurl, Allegro 5 and Qt 5.5) cmake . make 6.3. Building using MacOS X 41
  • 3.
    CHAPTER SEVEN HOW TO CONTRIBUTE? Ringis a free-open source project, Everyone is welcome to contribute to Ring. Project Home : https://github.com/ring-lang/ring You can help in many parts in the project • Documentation • Testing • Samples • Applications • Editors Support • Libraries in Ring • Extensions in C/C++ • Compiler and Virtual Machine (VM) • Ideas and suggestions 7.1 Special thanks to contributors Throughout the creation of this project, Ring relied heavily on contributions from experts along with college students. Their input was invaluable, and we want to take a moment to thank them and recognize them for all of their hard work. Ring Team: http://ring-lang.sf.net/team.html 7.2 Documentation You can modify anything in the documentation, by updating the text files (*.txt) in this folder : https://github.com/ring- lang/ring/tree/master/docs/source The documentation is created using Sphinx : http://www.sphinx-doc.org/en/stable/ 7.3 Testing You can write new tests in this folder https://github.com/ring-lang/ring/tree/master/tests/scripts 42
  • 4.
    Ring Documentation, Release1.2 7.4 Samples You can add new samples to this folder https://github.com/ring-lang/ring/tree/master/samples/other 7.5 Applications You can add new applications to this folder https://github.com/ring-lang/ring/tree/master/applications 7.6 Editors Support You can help in supporting Ring in different code editors Check the next folder https://github.com/ring-lang/ring/tree/master/editor 7.7 Libraries in Ring You can update and add libraries to this folder https://github.com/ring-lang/ring/tree/master/ringlibs 7.8 Extensions in C/C++ You can add and update extensions in this folder https://github.com/ring-lang/ring/tree/master/extensions 7.9 Compiler and Virtual Machine (VM) • Source Code (C Language) : https://github.com/ring-lang/ring/tree/master/src • Visual Source (PWCT) : https://github.com/ring-lang/ring/tree/master/visualsrc 7.10 Ideas and suggestions You can share your ideas, suggestions and questions in this group https://groups.google.com/forum/#!forum/ring-lang 7.4. Samples 43
  • 5.
    CHAPTER EIGHT GETTING STARTED -FIRST STYLE 8.1 Hello World The next program prints the Hello World message on the screen (std-out). see "Hello World" 8.2 Run the program to run the program, save the code in a file, for example : hello.ring then from the command line or terminal, run it using the ring interpreter ring hello.ring 8.3 Not Case-Sensitive Since the Ring language is not case-sensitive, the same program can be written in different styles Tip: It’s better to select one style and use it in all of the program source code SEE "Hello World" See "Hello World" 8.4 Multi-Line literals Using Ring we can write multi-line literal, see the next example See " Hello Welcome to the Ring programming language How are you? " Also you can use the nl constant to insert new line and you can use the + operator to concatenate strings 44
  • 6.
    Ring Documentation, Release1.2 Note: nl value means a new line and the actual codes that represent a newline is different between operating systems See "Hello" + nl + "Welcome to the Ring programming language" + nl + "How are you?" 8.5 Getting Input You can get the input from the user using the give command See "What is your name? " Give cName See "Hello " + cName 8.6 No Explicit End For Statements You don’t need to use ‘;’ or press ENTER to separate statements. The previous program can be written in one line. See "What is your name? " give cName see "Hello " + cName 8.7 Writing Comments We can write one line comments and multi-line comments The comment starts with # or // Multi-lines comments are written between /* and */ /* Program Name : My first program using Ring Date : 2016.09.09 Author : Mahmoud Fayed */ See "What is your name? " # print message on screen give cName # get input from the user see "Hello " + cName # say hello! // See "Bye!" Note: Using // to comment a lines of code is just a code style. 8.5. Getting Input 45
  • 7.
    CHAPTER NINE GETTING STARTED -SECOND STYLE 9.1 Hello World The next program prints the Hello World message on the screen (std-out). put "Hello World" 9.2 Run the program to run the program, save the code in a file, for example : hello.ring then from the command line or terminal, run it using the ring interpreter ring hello.ring 9.3 Not Case-Sensitive Since the Ring language is not case-sensitive, the same program can be written in different styles Tip: It’s better to select one style and use it in all of the program source code PUT "Hello World" Put "Hello World" 9.4 Multi-Line literals Using Ring we can write multi-line literal, see the next example Put " Hello Welcome to the Ring programming language How are you? " Also you can use the nl constant to insert new line and you can use the + operator to concatenate strings 46
  • 8.
    Ring Documentation, Release1.2 Note: nl value means a new line and the actual codes that represent a newline is different between operating systems Put "Hello" + nl + "Welcome to the Ring programming language" + nl + "How are you?" 9.5 Getting Input You can get the input from the user using the get command Put "What is your name? " Get cName Put "Hello " + cName 9.6 No Explicit End For Statements You don’t need to use ‘;’ or press ENTER to separate statements. The previous program can be written in one line. Put "What is your name? " get cName put "Hello " + cName 9.7 Writing Comments We can write one line comments and multi-line comments The comment starts with # or // Multi-lines comments are written between /* and */ /* Program Name : My first program using Ring Date : 2016.09.09 Author : Mahmoud Fayed */ Put "What is your name? " # print message on screen get cName # get input from the user put "Hello " + cName # say hello! // Put "Bye!" Note: Using // to comment a lines of code is just a code style. 9.5. Getting Input 47
  • 9.
    CHAPTER TEN GETTING STARTED -THIRD STYLE 10.1 Hello World The next program prints the Hello World message on the screen (std-out). load "stdlib.ring" print("Hello World") 10.2 Run the program to run the program, save the code in a file, for example : hello.ring then from the command line or terminal, run it using the ring interpreter ring hello.ring 10.3 Not Case-Sensitive Since the Ring language is not case-sensitive, the same program can be written in different styles Tip: It’s better to select one style and use it in all of the program source code LOAD "stdlib.ring" PRINT("Hello World") Load "stdlib.ring" Print("Hello World") 10.4 Multi-Line literals Using Ring we can write multi-line literal, see the next example Load "stdlib.ring" Print(" Hello Welcome to the Ring programming language How are you? 48
  • 10.
    Ring Documentation, Release1.2 ") Also you can use the n to insert new line and you can use #{variable_name} to insert variables values. Load "stdlib.ring" Print( "HellonWelcome to the Ring programming languagenHow are you?") 10.5 Getting Input You can get the input from the user using the getstring() function Load "stdlib.ring" Print("What is your name? ") cName = GetString() Print("Hello #{cName}") 10.6 No Explicit End For Statements You don’t need to use ‘;’ or press ENTER to separate statements. The previous program can be written in one line. Load "stdlib.ring" Print("What is your name? ") cName=getstring() print("Hello #{cName}") 10.7 Writing Comments We can write one line comments and multi-line comments The comment starts with # or // Multi-lines comments are written between /* and */ /* Program Name : My first program using Ring Date : 2016.09.09 Author : Mahmoud Fayed */ Load "stdlib.ring" Print("What is your name? ") # print message on screen cName=GetString() # get input from the user print("Hello #{cName}") # say hello! // print("Bye!") Note: Using // to comment a lines of code is just a code style. 10.5. Getting Input 49