SlideShare a Scribd company logo
1 of 10
Download to read offline
CHAPTER
TWELVE
GETTING STARTED - FIRST STYLE
12.1 Hello World
The next program prints the Hello World message on the screen (std-out).
see "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 Ring
ring hello.ring
12.3 Create Executable File
Using Ring2EXE we can create executable file for our application
ring2exe hello.ring -static
12.4 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"
12.5 Multi-Line literals
Using Ring we can write multi-line literal, see the next example
143
Ring Documentation, Release 1.6
See "
Hello
Welcome to the Ring programming language
How are you?
"
Also you can use the nl variable to insert new line and you can use the + operator to concatenate strings
As we have NL for new lines, we have Tab and CR (Carriage return) too!
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?"
12.6 Getting Input
You can get the input from the user using the give command
See "What is your name? "
Give cName
See "Hello " + cName
12.7 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
12.8 Using ? to print expression then new line
It’s common to print new line after printing an expression, We can use the ? operator to do that!
Example:
? "Hello, World!"
for x = 1 to 10
? x
next
Output:
Hello, World!
1
2
3
4
5
6
7
8
12.6. Getting Input 144
Ring Documentation, Release 1.6
9
10
12.9 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.
12.9. Writing Comments 145
CHAPTER
THIRTEEN
GETTING STARTED - SECOND STYLE
13.1 Hello World
The next program prints the Hello World message on the screen (std-out).
put "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 Ring
ring hello.ring
13.3 Create Executable File
Using Ring2EXE we can create executable file for our application
ring2exe hello.ring -static
13.4 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"
13.5 Multi-Line literals
Using Ring we can write multi-line literal, see the next example
146
Ring Documentation, Release 1.6
Put "
Hello
Welcome to the Ring programming language
How are you?
"
Also you can use the nl variable to insert new line and you can use the + operator to concatenate strings
As we have NL for new lines, we have Tab and CR (Carriage return) too!
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?"
13.6 Getting Input
You can get the input from the user using the get command
Put "What is your name? "
Get cName
Put "Hello " + cName
13.7 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
13.8 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.
13.6. Getting Input 147
CHAPTER
FOURTEEN
GETTING STARTED - THIRD STYLE
14.1 Hello World
The next program prints the Hello World message on the screen (std-out).
load "stdlib.ring"
print("Hello World")
14.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 Ring
ring hello.ring
14.3 Create Executable File
Using Ring2EXE we can create executable file for our application
ring2exe hello.ring -static
The -static option will avoid the need to ring.dll|ring.so|ring.dylib
But since the stdlib.ring load libraries like (LibCurl, OpenSSL, MySQL, etc)
You will need these libraries!
To avoid the need to these libraries (If you don’t need stdlib classes)
Use stdlibcore.ring instead of stdlib.ring as in the next example
load "stdlibcore.ring"
print("Hello World")
Using stdlibcore.ring You can access the stdlib functions but not the stdlib classes.
if you want to use stdlib.ring and distribute your application
ring2exe hello.ring -dist -allruntime -noqt -noallegro
148
Ring Documentation, Release 1.6
14.4 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")
14.5 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?
")
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?")
14.6 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}")
14.7 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}")
14.8 Writing Comments
We can write one line comments and multi-line comments
14.4. Not Case-Sensitive 149
Ring Documentation, Release 1.6
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.
14.8. Writing Comments 150
CHAPTER
FIFTEEN
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.
15.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
151
Ring Documentation, Release 1.6
15.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
15.2. Creating and running your first Console Application 152

More Related Content

What's hot

His162013 140529214456-phpapp01
His162013 140529214456-phpapp01His162013 140529214456-phpapp01
His162013 140529214456-phpapp01
Getachew Ganfur
 
Ui testing for Windows Phone
Ui testing for Windows PhoneUi testing for Windows Phone
Ui testing for Windows Phone
Stuart Lodge
 
Chapter1 introduction it2
Chapter1 introduction it2Chapter1 introduction it2
Chapter1 introduction it2
Kinglan Galon
 

What's hot (11)

His162013 140529214456-phpapp01
His162013 140529214456-phpapp01His162013 140529214456-phpapp01
His162013 140529214456-phpapp01
 
Javascript cheatsheet
Javascript cheatsheetJavascript cheatsheet
Javascript cheatsheet
 
How to Dockerize, Automate the Build and Deployment Process for Flutter?
How to Dockerize, Automate the Build and Deployment Process for Flutter?How to Dockerize, Automate the Build and Deployment Process for Flutter?
How to Dockerize, Automate the Build and Deployment Process for Flutter?
 
C plus plus for hackers it security
C plus plus for hackers it securityC plus plus for hackers it security
C plus plus for hackers it security
 
Ui testing for Windows Phone
Ui testing for Windows PhoneUi testing for Windows Phone
Ui testing for Windows Phone
 
제 4회 DGMIT R&D 컨퍼런스 : Making a JavaScript based Application in Mac OS X
제 4회 DGMIT R&D 컨퍼런스 : Making a JavaScript based Application in Mac OS X제 4회 DGMIT R&D 컨퍼런스 : Making a JavaScript based Application in Mac OS X
제 4회 DGMIT R&D 컨퍼런스 : Making a JavaScript based Application in Mac OS X
 
Programming Without Coding Technology (PWCT) Features - Framework & Extension
Programming Without Coding Technology (PWCT) Features - Framework & ExtensionProgramming Without Coding Technology (PWCT) Features - Framework & Extension
Programming Without Coding Technology (PWCT) Features - Framework & Extension
 
Formula injection/DDE/Macro
Formula injection/DDE/MacroFormula injection/DDE/Macro
Formula injection/DDE/Macro
 
Chapter1 introduction it2
Chapter1 introduction it2Chapter1 introduction it2
Chapter1 introduction it2
 
Delphi COM Programming
Delphi COM ProgrammingDelphi COM Programming
Delphi COM Programming
 
PhoneGap Application Development - Santhi J Krishnan
PhoneGap Application Development - Santhi J KrishnanPhoneGap Application Development - Santhi J Krishnan
PhoneGap Application Development - Santhi J Krishnan
 

Similar to The Ring programming language version 1.6 book - Part 18 of 189

Similar to The Ring programming language version 1.6 book - Part 18 of 189 (20)

The Ring programming language version 1.5.2 book - Part 16 of 181
The Ring programming language version 1.5.2 book - Part 16 of 181The Ring programming language version 1.5.2 book - Part 16 of 181
The Ring programming language version 1.5.2 book - Part 16 of 181
 
The Ring programming language version 1.8 book - Part 20 of 202
The Ring programming language version 1.8 book - Part 20 of 202The Ring programming language version 1.8 book - Part 20 of 202
The Ring programming language version 1.8 book - Part 20 of 202
 
The Ring programming language version 1.5.4 book - Part 16 of 185
The Ring programming language version 1.5.4 book - Part 16 of 185The Ring programming language version 1.5.4 book - Part 16 of 185
The Ring programming language version 1.5.4 book - Part 16 of 185
 
The Ring programming language version 1.5.3 book - Part 16 of 184
The Ring programming language version 1.5.3 book - Part 16 of 184The Ring programming language version 1.5.3 book - Part 16 of 184
The Ring programming language version 1.5.3 book - Part 16 of 184
 
The Ring programming language version 1.2 book - Part 7 of 84
The Ring programming language version 1.2 book - Part 7 of 84The Ring programming language version 1.2 book - Part 7 of 84
The Ring programming language version 1.2 book - Part 7 of 84
 
The Ring programming language version 1.5.4 book - Part 17 of 185
The Ring programming language version 1.5.4 book - Part 17 of 185The Ring programming language version 1.5.4 book - Part 17 of 185
The Ring programming language version 1.5.4 book - Part 17 of 185
 
C++ for hackers
C++ for hackersC++ for hackers
C++ for hackers
 
The Ring programming language version 1.5.3 book - Part 17 of 184
The Ring programming language version 1.5.3 book - Part 17 of 184The Ring programming language version 1.5.3 book - Part 17 of 184
The Ring programming language version 1.5.3 book - Part 17 of 184
 
C
CC
C
 
C language industrial training report
C language industrial training reportC language industrial training report
C language industrial training report
 
The Ring programming language version 1.9 book - Part 22 of 210
The Ring programming language version 1.9 book - Part 22 of 210The Ring programming language version 1.9 book - Part 22 of 210
The Ring programming language version 1.9 book - Part 22 of 210
 
C-PROGRAMMING-LANGUAGE.pptx
C-PROGRAMMING-LANGUAGE.pptxC-PROGRAMMING-LANGUAGE.pptx
C-PROGRAMMING-LANGUAGE.pptx
 
Intro To C++ - Class 3 - Sample Program
Intro To C++ - Class 3 - Sample ProgramIntro To C++ - Class 3 - Sample Program
Intro To C++ - Class 3 - Sample Program
 
Intro To C++ - Class 03 - An Introduction To C++ Programming, Part II
Intro To C++ - Class 03 - An Introduction To C++ Programming, Part IIIntro To C++ - Class 03 - An Introduction To C++ Programming, Part II
Intro To C++ - Class 03 - An Introduction To C++ Programming, Part II
 
The Ring programming language version 1.7 book - Part 20 of 196
The Ring programming language version 1.7 book - Part 20 of 196The Ring programming language version 1.7 book - Part 20 of 196
The Ring programming language version 1.7 book - Part 20 of 196
 
The Ring programming language version 1.5.1 book - Part 16 of 180
The Ring programming language version 1.5.1 book - Part 16 of 180The Ring programming language version 1.5.1 book - Part 16 of 180
The Ring programming language version 1.5.1 book - Part 16 of 180
 
The Ring programming language version 1.5.2 book - Part 15 of 181
The Ring programming language version 1.5.2 book - Part 15 of 181The Ring programming language version 1.5.2 book - Part 15 of 181
The Ring programming language version 1.5.2 book - Part 15 of 181
 
Android
AndroidAndroid
Android
 
Programming
ProgrammingProgramming
Programming
 
INTRODUCTION TO C PROGRAMMING MATERIAL.pdf
INTRODUCTION TO C PROGRAMMING MATERIAL.pdfINTRODUCTION TO C PROGRAMMING MATERIAL.pdf
INTRODUCTION TO C PROGRAMMING MATERIAL.pdf
 

More from Mahmoud Samir Fayed

More from Mahmoud Samir Fayed (20)

The Ring programming language version 1.10 book - Part 212 of 212
The Ring programming language version 1.10 book - Part 212 of 212The Ring programming language version 1.10 book - Part 212 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 211 of 212The Ring programming language version 1.10 book - Part 211 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 210 of 212The Ring programming language version 1.10 book - Part 210 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 208 of 212The Ring programming language version 1.10 book - Part 208 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 207 of 212The Ring programming language version 1.10 book - Part 207 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 205 of 212The Ring programming language version 1.10 book - Part 205 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 206 of 212The Ring programming language version 1.10 book - Part 206 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 204 of 212The Ring programming language version 1.10 book - Part 204 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 203 of 212The Ring programming language version 1.10 book - Part 203 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 202 of 212The Ring programming language version 1.10 book - Part 202 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 201 of 212The Ring programming language version 1.10 book - Part 201 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 200 of 212The Ring programming language version 1.10 book - Part 200 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 199 of 212The Ring programming language version 1.10 book - Part 199 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 198 of 212The Ring programming language version 1.10 book - Part 198 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 197 of 212The Ring programming language version 1.10 book - Part 197 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 196 of 212The Ring programming language version 1.10 book - Part 196 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 195 of 212The Ring programming language version 1.10 book - Part 195 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 194 of 212The Ring programming language version 1.10 book - Part 194 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 193 of 212The Ring programming language version 1.10 book - Part 193 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
The Ring programming language version 1.10 book - Part 192 of 212The Ring programming language version 1.10 book - Part 192 of 212
The Ring programming language version 1.10 book - Part 192 of 212
 

Recently uploaded

CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 

Recently uploaded (20)

call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 

The Ring programming language version 1.6 book - Part 18 of 189

  • 1. CHAPTER TWELVE GETTING STARTED - FIRST STYLE 12.1 Hello World The next program prints the Hello World message on the screen (std-out). see "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 Ring ring hello.ring 12.3 Create Executable File Using Ring2EXE we can create executable file for our application ring2exe hello.ring -static 12.4 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" 12.5 Multi-Line literals Using Ring we can write multi-line literal, see the next example 143
  • 2. Ring Documentation, Release 1.6 See " Hello Welcome to the Ring programming language How are you? " Also you can use the nl variable to insert new line and you can use the + operator to concatenate strings As we have NL for new lines, we have Tab and CR (Carriage return) too! 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?" 12.6 Getting Input You can get the input from the user using the give command See "What is your name? " Give cName See "Hello " + cName 12.7 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 12.8 Using ? to print expression then new line It’s common to print new line after printing an expression, We can use the ? operator to do that! Example: ? "Hello, World!" for x = 1 to 10 ? x next Output: Hello, World! 1 2 3 4 5 6 7 8 12.6. Getting Input 144
  • 3. Ring Documentation, Release 1.6 9 10 12.9 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. 12.9. Writing Comments 145
  • 4. CHAPTER THIRTEEN GETTING STARTED - SECOND STYLE 13.1 Hello World The next program prints the Hello World message on the screen (std-out). put "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 Ring ring hello.ring 13.3 Create Executable File Using Ring2EXE we can create executable file for our application ring2exe hello.ring -static 13.4 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" 13.5 Multi-Line literals Using Ring we can write multi-line literal, see the next example 146
  • 5. Ring Documentation, Release 1.6 Put " Hello Welcome to the Ring programming language How are you? " Also you can use the nl variable to insert new line and you can use the + operator to concatenate strings As we have NL for new lines, we have Tab and CR (Carriage return) too! 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?" 13.6 Getting Input You can get the input from the user using the get command Put "What is your name? " Get cName Put "Hello " + cName 13.7 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 13.8 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. 13.6. Getting Input 147
  • 6. CHAPTER FOURTEEN GETTING STARTED - THIRD STYLE 14.1 Hello World The next program prints the Hello World message on the screen (std-out). load "stdlib.ring" print("Hello World") 14.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 Ring ring hello.ring 14.3 Create Executable File Using Ring2EXE we can create executable file for our application ring2exe hello.ring -static The -static option will avoid the need to ring.dll|ring.so|ring.dylib But since the stdlib.ring load libraries like (LibCurl, OpenSSL, MySQL, etc) You will need these libraries! To avoid the need to these libraries (If you don’t need stdlib classes) Use stdlibcore.ring instead of stdlib.ring as in the next example load "stdlibcore.ring" print("Hello World") Using stdlibcore.ring You can access the stdlib functions but not the stdlib classes. if you want to use stdlib.ring and distribute your application ring2exe hello.ring -dist -allruntime -noqt -noallegro 148
  • 7. Ring Documentation, Release 1.6 14.4 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") 14.5 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? ") 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?") 14.6 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}") 14.7 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}") 14.8 Writing Comments We can write one line comments and multi-line comments 14.4. Not Case-Sensitive 149
  • 8. Ring Documentation, Release 1.6 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. 14.8. Writing Comments 150
  • 9. CHAPTER FIFTEEN 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. 15.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 151
  • 10. Ring Documentation, Release 1.6 15.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 15.2. Creating and running your first Console Application 152