SlideShare a Scribd company logo
Ring Documentation, Release 1.5.1
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?"
11.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
11.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
11.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.
11.5. Getting Input 115
CHAPTER
TWELVE
GETTING STARTED - SECOND STYLE
12.1 Hello World
The next program prints the Hello World message on the screen (std-out).
put "Hello World"
12.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
12.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"
12.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
116
Ring Documentation, Release 1.5.1
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?"
12.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
12.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
12.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.
12.5. Getting Input 117
CHAPTER
THIRTEEN
GETTING STARTED - THIRD STYLE
13.1 Hello World
The next program prints the Hello World message on the screen (std-out).
load "stdlib.ring"
print("Hello World")
13.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
13.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")
13.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?
118
Ring Documentation, Release 1.5.1
")
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?")
13.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}")
13.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}")
13.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.
13.5. Getting Input 119
CHAPTER
FOURTEEN
USING RING NOTEPAD
In this chapter we will learn about using Ring Notepad to write and execute Ring programs quickly
Ring Notepad is just a simple application developed using the Ring language.
14.1 Ring Notepad - Main Window
When we run the Ring Notepad we get the next dockable windows
• Project Files Window : where we can select and open any ring file (*.ring) quickly.
• Source Code Window : Where we write the source code.
• Form Designer Window : The Form Designer to create GUI application forms.
• Web Browser Window : Where we read the documentation or quickly open any website.
• Output Window : Output when we run programs that print to the standard output
• Function Window : List of functions in the current source file
• Classes Window : List of classes in the current source file
120
Ring Documentation, Release 1.5.1
14.2 Creating and running your first Console Application
At first we will type the source code
See "Hello, World!"
As in the next image
Then we will click on the “Save” button from the toolbar (or press CTRL+S)
Determine the source code file name and location.
For example type : hello
This will create a new source code file called : hello.ring
14.2. Creating and running your first Console Application 121
Ring Documentation, Release 1.5.1
To run the program click on “Debug (Run then wait!)” button from the toolbar
The next screen shot present the application during the runtime
Press Enter to continue and return to the Ring Notepad.
14.2. Creating and running your first Console Application 122
Ring Documentation, Release 1.5.1
14.3 Creating and running your first GUI/Mobile Application
To learn how to create GUI applications using Ring check the “Desktop and Mobile development using RingQt”
chapter.
Source Code:
Load "guilib.ring"
New qApp {
new qWidget() {
resize(400,400)
setWindowTitle("Hello, World!")
show()
}
exec()
}
In Ring notepad we have a special button to run GUI applications without displaying the console window.
14.3. Creating and running your first GUI/Mobile Application 123
Ring Documentation, Release 1.5.1
The next screen shot present the application during the runtime
14.4 Creating and running your first Web Application
To learn how support Ring in your web server and how to create web applications using Ring check the “Web Devel-
opment (CGI Library)” chapter.
Note: You need to support the Ring language in your web server to be able to run the next example.
Source Code:
14.4. Creating and running your first Web Application 124

More Related Content

PDF
The Ring programming language version 1.3 book - Part 9 of 88
PDF
The Ring programming language version 1.5.2 book - Part 16 of 181
PDF
The Ring programming language version 1.4 book - Part 4 of 30
PDF
The Ring programming language version 1.6 book - Part 18 of 189
PDF
The Ring programming language version 1.5.4 book - Part 17 of 185
PDF
The Ring programming language version 1.5.3 book - Part 17 of 184
ODP
BIS07 Application Development - I
PPTX
Ui testing for Windows Phone
The Ring programming language version 1.3 book - Part 9 of 88
The Ring programming language version 1.5.2 book - Part 16 of 181
The Ring programming language version 1.4 book - Part 4 of 30
The Ring programming language version 1.6 book - Part 18 of 189
The Ring programming language version 1.5.4 book - Part 17 of 185
The Ring programming language version 1.5.3 book - Part 17 of 184
BIS07 Application Development - I
Ui testing for Windows Phone

What's hot (11)

PDF
The Ring programming language version 1.2 book - Part 8 of 84
PPT
PPT
PPTX
Android the first app - hello world - copy
PDF
The Ring programming language version 1.7 book - Part 20 of 196
PPTX
Formula injection/DDE/Macro
PPTX
Windows Universal Apps
PPTX
Fall summit 11
PPTX
Expression studio overview_MVP Kok Chiann
DOCX
Lect '1'
The Ring programming language version 1.2 book - Part 8 of 84
Android the first app - hello world - copy
The Ring programming language version 1.7 book - Part 20 of 196
Formula injection/DDE/Macro
Windows Universal Apps
Fall summit 11
Expression studio overview_MVP Kok Chiann
Lect '1'
Ad

Similar to The Ring programming language version 1.5.1 book - Part 15 of 180 (20)

PDF
The Ring programming language version 1.10 book - Part 24 of 212
PDF
The Ring programming language version 1.7 book - Part 19 of 196
PDF
The Ring programming language version 1.9 book - Part 23 of 210
PDF
The Ring programming language version 1.5.3 book - Part 16 of 184
PDF
The Ring programming language version 1.4.1 book - Part 4 of 31
PDF
The Ring programming language version 1.8 book - Part 21 of 202
PDF
The Ring programming language version 1.5.4 book - Part 16 of 185
PDF
The Ring programming language version 1.2 book - Part 7 of 84
PDF
The Ring programming language version 1.8 book - Part 20 of 202
PDF
The Ring programming language version 1.9 book - Part 22 of 210
PDF
The Ring programming language version 1.5.2 book - Part 15 of 181
PDF
The Ring programming language version 1.10 book - Part 7 of 212
PDF
The Ring programming language version 1.9 book - Part 7 of 210
PDF
The Ring programming language version 1.6 book - Part 7 of 189
PDF
The Ring programming language version 1.4 book - Part 5 of 30
PDF
The Ring programming language version 1.5.4 book - Part 20 of 185
PDF
The Ring programming language version 1.5.2 book - Part 19 of 181
PDF
The Ring programming language version 1.3 book - Part 4 of 88
PDF
The Ring programming language version 1.5.3 book - Part 20 of 184
PDF
The Ring programming language version 1.3 book - Part 12 of 88
The Ring programming language version 1.10 book - Part 24 of 212
The Ring programming language version 1.7 book - Part 19 of 196
The Ring programming language version 1.9 book - Part 23 of 210
The Ring programming language version 1.5.3 book - Part 16 of 184
The Ring programming language version 1.4.1 book - Part 4 of 31
The Ring programming language version 1.8 book - Part 21 of 202
The Ring programming language version 1.5.4 book - Part 16 of 185
The Ring programming language version 1.2 book - Part 7 of 84
The Ring programming language version 1.8 book - Part 20 of 202
The Ring programming language version 1.9 book - Part 22 of 210
The Ring programming language version 1.5.2 book - Part 15 of 181
The Ring programming language version 1.10 book - Part 7 of 212
The Ring programming language version 1.9 book - Part 7 of 210
The Ring programming language version 1.6 book - Part 7 of 189
The Ring programming language version 1.4 book - Part 5 of 30
The Ring programming language version 1.5.4 book - Part 20 of 185
The Ring programming language version 1.5.2 book - Part 19 of 181
The Ring programming language version 1.3 book - Part 4 of 88
The Ring programming language version 1.5.3 book - Part 20 of 184
The Ring programming language version 1.3 book - Part 12 of 88
Ad

More from Mahmoud Samir Fayed (20)

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

Recently uploaded (20)

PPT
Teaching material agriculture food technology
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Machine learning based COVID-19 study performance prediction
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
MYSQL Presentation for SQL database connectivity
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Approach and Philosophy of On baking technology
PDF
Electronic commerce courselecture one. Pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
Understanding_Digital_Forensics_Presentation.pptx
Teaching material agriculture food technology
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
20250228 LYD VKU AI Blended-Learning.pptx
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Programs and apps: productivity, graphics, security and other tools
Encapsulation_ Review paper, used for researhc scholars
Machine learning based COVID-19 study performance prediction
Dropbox Q2 2025 Financial Results & Investor Presentation
MYSQL Presentation for SQL database connectivity
NewMind AI Weekly Chronicles - August'25 Week I
Approach and Philosophy of On baking technology
Electronic commerce courselecture one. Pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
The Rise and Fall of 3GPP – Time for a Sabbatical?
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Mobile App Security Testing_ A Comprehensive Guide.pdf
Advanced methodologies resolving dimensionality complications for autism neur...
Reach Out and Touch Someone: Haptics and Empathic Computing
The AUB Centre for AI in Media Proposal.docx
Understanding_Digital_Forensics_Presentation.pptx

The Ring programming language version 1.5.1 book - Part 15 of 180

  • 1. Ring Documentation, Release 1.5.1 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?" 11.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 11.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 11.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. 11.5. Getting Input 115
  • 2. CHAPTER TWELVE GETTING STARTED - SECOND STYLE 12.1 Hello World The next program prints the Hello World message on the screen (std-out). put "Hello World" 12.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 12.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" 12.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 116
  • 3. Ring Documentation, Release 1.5.1 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?" 12.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 12.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 12.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. 12.5. Getting Input 117
  • 4. CHAPTER THIRTEEN GETTING STARTED - THIRD STYLE 13.1 Hello World The next program prints the Hello World message on the screen (std-out). load "stdlib.ring" print("Hello World") 13.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 13.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") 13.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? 118
  • 5. Ring Documentation, Release 1.5.1 ") 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?") 13.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}") 13.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}") 13.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. 13.5. Getting Input 119
  • 6. CHAPTER FOURTEEN USING RING NOTEPAD In this chapter we will learn about using Ring Notepad to write and execute Ring programs quickly Ring Notepad is just a simple application developed using the Ring language. 14.1 Ring Notepad - Main Window When we run the Ring Notepad we get the next dockable windows • Project Files Window : where we can select and open any ring file (*.ring) quickly. • Source Code Window : Where we write the source code. • Form Designer Window : The Form Designer to create GUI application forms. • Web Browser Window : Where we read the documentation or quickly open any website. • Output Window : Output when we run programs that print to the standard output • Function Window : List of functions in the current source file • Classes Window : List of classes in the current source file 120
  • 7. Ring Documentation, Release 1.5.1 14.2 Creating and running your first Console Application At first we will type the source code See "Hello, World!" As in the next image Then we will click on the “Save” button from the toolbar (or press CTRL+S) Determine the source code file name and location. For example type : hello This will create a new source code file called : hello.ring 14.2. Creating and running your first Console Application 121
  • 8. Ring Documentation, Release 1.5.1 To run the program click on “Debug (Run then wait!)” button from the toolbar The next screen shot present the application during the runtime Press Enter to continue and return to the Ring Notepad. 14.2. Creating and running your first Console Application 122
  • 9. Ring Documentation, Release 1.5.1 14.3 Creating and running your first GUI/Mobile Application To learn how to create GUI applications using Ring check the “Desktop and Mobile development using RingQt” chapter. Source Code: Load "guilib.ring" New qApp { new qWidget() { resize(400,400) setWindowTitle("Hello, World!") show() } exec() } In Ring notepad we have a special button to run GUI applications without displaying the console window. 14.3. Creating and running your first GUI/Mobile Application 123
  • 10. Ring Documentation, Release 1.5.1 The next screen shot present the application during the runtime 14.4 Creating and running your first Web Application To learn how support Ring in your web server and how to create web applications using Ring check the “Web Devel- opment (CGI Library)” chapter. Note: You need to support the Ring language in your web server to be able to run the next example. Source Code: 14.4. Creating and running your first Web Application 124