SlideShare a Scribd company logo
1 of 10
Download to read offline
Ring Documentation, Release 1.5.3
x = 1 / 0
catch
see "catching error" + nl
}
Output:
if statement..
one
for loop..
12345678910
switch...
one
try catch...
catching error
62.11 Using ‘put’ and ‘get’ as ‘see’ and ‘give’
We can replace the ‘see’ keyword with the ‘put’ keyword.
Also we can replacew the ‘give’ keyword with the ‘get’ keyword.
Example:
put "Hello World" + nl
put "Enter Your Name ? " Get Name
Put "Hello " + Name
62.12 Using ‘case’ as ‘on’ in switch statements
We can replace the ‘on’ keyword with ‘case’ keyword in the switch statement.
Example (1) :
for x=1 to 10
switch x
case 1 put "one" + nl
case 2 put "two" + nl
case 3 put "thre" + nl
else put "else" + nl
end
end
Example (2) :
for x=1 to 10 {
switch x {
case 1 put "one" + nl
case 2 put "two" + nl
case 3 put "thre" + nl
else put "else" + nl
}
}
62.11. Using ‘put’ and ‘get’ as ‘see’ and ‘give’ 715
Ring Documentation, Release 1.5.3
62.13 Using ‘def’ as ‘func’ in functions/methods definition
We can use the ‘def’ keyword as the ‘func’ keyword to define functions and methods.
Example:
one() two()
def one put "one" + nl
def two put "two" + nl
62.14 Using braces { } in Packages/Classes/Functions
Example:
load "stdlib.ring"
import mypackage
new myclass {
myfunc()
}
package mypackage
{
class myclass
{
func myfunc
{
print("Hello, World!n")
}
}
}
62.15 Using ‘end’ keyword after Packages/Classes/Functions
Example:
import mypackage
new myclass {
myfunc()
}
package mypackage
class myclass
def myfunc
put "Hello, World!"
end
end
end
62.13. Using ‘def’ as ‘func’ in functions/methods definition 716
Ring Documentation, Release 1.5.3
62.16 Using ‘endpackage’/’endclass’/’endfunc’ keywords after Pack-
ages/Classes/Functions
Example:
import mypackage
new myclass { myfunc() }
package mypackage
class myclass
func myfunc
see "welcome" + nl
endfunc
endclass
endpackage
62.16. Using ‘endpackage’/’endclass’/’endfunc’ keywords after Packages/Classes/Functions 717
CHAPTER
SIXTYTHREE
INTRODUCTION TO THE TYPE HINTS LIBRARY
In this chapter we will learn about the Type Hints Library
63.1 Why Type Hints?
Using this library we can add the type information to the source code which will be very useful for tools like
• Code Editors
• Static-Analysis
Note: Ring is a dynamic language, No type checking will be done by the compiler.
63.2 Example
The next example will use the Type Hints library
load "typehints.ring"
see sum(3,4) + nl ;
see sayHello("Mahmoud");
int func sum(int x,int y) {
return x+y ;
}
string func sayHello(string name) {
return "Hello " + name ;
}
63.3 User Types
The Type Hints library is very powerful and will support user types (Classes) automatically
Example:
load "typehints.ring"
import mypackage
718
Ring Documentation, Release 1.5.3
test() { main([:one,:two,:three]) }
myclass func test() {
see "Testing User Types!" + nl
return new myclass
}
package mypackage {
public class myclass {
public static void func main(list args) {
see "welcome" + nl
see args
}
}
}
63.4 Using Types inside Code
Also you can use the types inside the code (not only the function prototype)
Example:
load "typehints.ring"
int sum = sum(3,4)
string msg = sayHello("Mahmoud")
see "Sum = " + sum + nl + msg + nl
int func sum(int x,int y) {
return x+y ;
}
string func sayHello(string name) {
return "Hello " + name ;
}
63.5 Rules
• To use the types in the function prototype you must use ‘(‘ and ‘)’ around parameters
• To use the types in the function code, You must set the variable value (Assignment).
The next types are defined by the library
# Low Level Types
char
unsigned
signed
int
short
long
float
63.4. Using Types inside Code 719
Ring Documentation, Release 1.5.3
double
void
# High Level Types
string
list
number
object
# Other
public
static
abstract
protected
override
63.5. Rules 720
CHAPTER
SIXTYFOUR
DISTRIBUTING RING APPLICATIONS
In this chapter we will learn about distributing Ring applications.
64.1 Distributing Applications for Microsoft Windows
Step 1:
Copy c:ringbin folder to be for example c:myapp
Step 2:
Rename c:myappring.exe to c:myappmyapp.exe
Step 3:
Create a file c:myappring.ring
And write
Load "myapp.ring"
When you run myapp.exe the file ring.ring will be executed automatically
So your file myapp.ring will be called and executed
Or just rename myapp.ring to ring.ring
It’s a fast way to distribute applications.
64.2 Protecting the Source Code
Step 1:
Execute the next command
ring myapp.ring -go
This will generate one object file (myapp.ringo) from the project files (*.ring)
Step 2:
Rename myapp.ringo to ring.ringo
When you run the executable file (ring.exe) or (myapp.exe) the file ring.ringo will be executed.
721
Ring Documentation, Release 1.5.3
64.3 Creating Windows Installer
There are many tools that you can use to distribute your application.
Check : nullsoft scriptable install system
URL : http://nsis.sourceforge.net/Main_Page
64.4 Using C/C++ Compiler and Linker
Another method to distribute applications is to use a C/C++ compiler.
Ring can be embedded in C/C++ projects, We can create executable files using a C/C++ compiler by embedding the
Ring language in our project.
Check the “Embedding Ring Language in C/C++ Programs” chapter.
Using this way we will avoid using ring.ring or ring.ringo files.
64.5 Distributing Applications and Games for Mobile
Ring can be embedded in a Qt projects or LibSDL projects to build Mobile applications and Games.
You can build the Qt project or the LibSDL project and get the Android package directly (*.apk)
Check Ring distributions for Mobile development using Qt or LibSDL.
64.3. Creating Windows Installer 722
CHAPTER
SIXTYFIVE
COMMAND LINE OPTIONS
The ring language takes source code file (.ring) or the object file (.ringo) as input to execute, also the language provide
other options like
Option Description
-tokens Print a list of tokens in the source code file
-rules Print grammar rules applied on the tokens
-ic Print the intermediate byte code (before execution)
-icfinal Print the final byte code (after execution)
-cgi Print http response header before error messages
-norun Don’t run the program after compiling
-ins Print instruction operation code before execution
-performance Print clock before and after program execution
-go Generate Object File
-w Display Warnings
65.1 Printing Tokens
Example:
Func Main
See "Hello World" + nl
for x = 1 to 10
see x + nl
next
test()
func test
see "welcome" + nl
o1 = new point { x=10 y=20 z=30 }
see o1
class point x y z
Command:
ring test.ring -tokens -norun
Output:
===================================================
Tokens - Generated by the Scanner
===================================================
723
Ring Documentation, Release 1.5.3
Keyword : FUNC
Identifier : main
EndLine
Keyword : SEE
Literal : Hello World
Operator : +
Identifier : nl
EndLine
Keyword : FOR
Identifier : x
Operator : =
Number : 1
Keyword : TO
Number : 10
EndLine
Keyword : SEE
Identifier : x
Operator : +
Identifier : nl
EndLine
Keyword : NEXT
EndLine
Identifier : test
Operator : (
Operator : )
EndLine
Keyword : FUNC
Identifier : test
EndLine
Keyword : SEE
Literal : welcome
Operator : +
Identifier : nl
EndLine
Identifier : o1
Operator : =
Keyword : NEW
Identifier : point
Operator : {
Identifier : x
Operator : =
Number : 10
Identifier : y
Operator : =
Number : 20
Identifier : z
Operator : =
Number : 30
Operator : }
EndLine
Keyword : SEE
Identifier : o1
EndLine
Keyword : CLASS
Identifier : point
Identifier : x
Identifier : y
Identifier : z
65.1. Printing Tokens 724

More Related Content

What's hot

Smarter Testing with Spock
Smarter Testing with SpockSmarter Testing with Spock
Smarter Testing with SpockDmitry Voloshko
 
Ian 2014.10.24 weekly report
Ian 2014.10.24 weekly reportIan 2014.10.24 weekly report
Ian 2014.10.24 weekly reportLearningTech
 
The Ring programming language version 1.5.3 book - Part 189 of 194
The Ring programming language version 1.5.3 book - Part 189 of 194The Ring programming language version 1.5.3 book - Part 189 of 194
The Ring programming language version 1.5.3 book - Part 189 of 194Mahmoud Samir Fayed
 
Smarter Testing With Spock
Smarter Testing With SpockSmarter Testing With Spock
Smarter Testing With SpockIT Weekend
 
Java programming lab_manual_by_rohit_jaiswar
Java programming lab_manual_by_rohit_jaiswarJava programming lab_manual_by_rohit_jaiswar
Java programming lab_manual_by_rohit_jaiswarROHIT JAISWAR
 
Advanced Java Practical File
Advanced Java Practical FileAdvanced Java Practical File
Advanced Java Practical FileSoumya Behera
 
Grails/Groovyによる開発事例紹介
Grails/Groovyによる開発事例紹介Grails/Groovyによる開発事例紹介
Grails/Groovyによる開発事例紹介Kiyotaka Oku
 
Java Concurrency Idioms
Java Concurrency IdiomsJava Concurrency Idioms
Java Concurrency IdiomsAlex Miller
 
The Ring programming language version 1.7 book - Part 92 of 196
The Ring programming language version 1.7 book - Part 92 of 196The Ring programming language version 1.7 book - Part 92 of 196
The Ring programming language version 1.7 book - Part 92 of 196Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 59 of 212
The Ring programming language version 1.10 book - Part 59 of 212The Ring programming language version 1.10 book - Part 59 of 212
The Ring programming language version 1.10 book - Part 59 of 212Mahmoud Samir Fayed
 
The Ring programming language version 1.7 book - Part 91 of 196
The Ring programming language version 1.7 book - Part 91 of 196The Ring programming language version 1.7 book - Part 91 of 196
The Ring programming language version 1.7 book - Part 91 of 196Mahmoud Samir Fayed
 
The Ring programming language version 1.5.2 book - Part 72 of 181
The Ring programming language version 1.5.2 book - Part 72 of 181The Ring programming language version 1.5.2 book - Part 72 of 181
The Ring programming language version 1.5.2 book - Part 72 of 181Mahmoud Samir Fayed
 
CS101- Introduction to Computing- Lecture 26
CS101- Introduction to Computing- Lecture 26CS101- Introduction to Computing- Lecture 26
CS101- Introduction to Computing- Lecture 26Bilal Ahmed
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAAiman Hud
 
The Ring programming language version 1.9 book - Part 99 of 210
The Ring programming language version 1.9 book - Part 99 of 210The Ring programming language version 1.9 book - Part 99 of 210
The Ring programming language version 1.9 book - Part 99 of 210Mahmoud Samir Fayed
 

What's hot (20)

Smarter Testing with Spock
Smarter Testing with SpockSmarter Testing with Spock
Smarter Testing with Spock
 
Spock framework
Spock frameworkSpock framework
Spock framework
 
Unit Testing with Foq
Unit Testing with FoqUnit Testing with Foq
Unit Testing with Foq
 
Ian 2014.10.24 weekly report
Ian 2014.10.24 weekly reportIan 2014.10.24 weekly report
Ian 2014.10.24 weekly report
 
The Ring programming language version 1.5.3 book - Part 189 of 194
The Ring programming language version 1.5.3 book - Part 189 of 194The Ring programming language version 1.5.3 book - Part 189 of 194
The Ring programming language version 1.5.3 book - Part 189 of 194
 
Smarter Testing With Spock
Smarter Testing With SpockSmarter Testing With Spock
Smarter Testing With Spock
 
Java programming lab_manual_by_rohit_jaiswar
Java programming lab_manual_by_rohit_jaiswarJava programming lab_manual_by_rohit_jaiswar
Java programming lab_manual_by_rohit_jaiswar
 
Advanced Java Practical File
Advanced Java Practical FileAdvanced Java Practical File
Advanced Java Practical File
 
Grails/Groovyによる開発事例紹介
Grails/Groovyによる開発事例紹介Grails/Groovyによる開発事例紹介
Grails/Groovyによる開発事例紹介
 
Spock Framework
Spock FrameworkSpock Framework
Spock Framework
 
Java Concurrency Idioms
Java Concurrency IdiomsJava Concurrency Idioms
Java Concurrency Idioms
 
The Ring programming language version 1.7 book - Part 92 of 196
The Ring programming language version 1.7 book - Part 92 of 196The Ring programming language version 1.7 book - Part 92 of 196
The Ring programming language version 1.7 book - Part 92 of 196
 
Java Lab Manual
Java Lab ManualJava Lab Manual
Java Lab Manual
 
The Ring programming language version 1.10 book - Part 59 of 212
The Ring programming language version 1.10 book - Part 59 of 212The Ring programming language version 1.10 book - Part 59 of 212
The Ring programming language version 1.10 book - Part 59 of 212
 
The Ring programming language version 1.7 book - Part 91 of 196
The Ring programming language version 1.7 book - Part 91 of 196The Ring programming language version 1.7 book - Part 91 of 196
The Ring programming language version 1.7 book - Part 91 of 196
 
The Ring programming language version 1.5.2 book - Part 72 of 181
The Ring programming language version 1.5.2 book - Part 72 of 181The Ring programming language version 1.5.2 book - Part 72 of 181
The Ring programming language version 1.5.2 book - Part 72 of 181
 
JDBC Core Concept
JDBC Core ConceptJDBC Core Concept
JDBC Core Concept
 
CS101- Introduction to Computing- Lecture 26
CS101- Introduction to Computing- Lecture 26CS101- Introduction to Computing- Lecture 26
CS101- Introduction to Computing- Lecture 26
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
The Ring programming language version 1.9 book - Part 99 of 210
The Ring programming language version 1.9 book - Part 99 of 210The Ring programming language version 1.9 book - Part 99 of 210
The Ring programming language version 1.9 book - Part 99 of 210
 

Similar to The Ring programming language version 1.5.3 book - Part 85 of 184

The Ring programming language version 1.10 book - Part 90 of 212
The Ring programming language version 1.10 book - Part 90 of 212The Ring programming language version 1.10 book - Part 90 of 212
The Ring programming language version 1.10 book - Part 90 of 212Mahmoud Samir Fayed
 
The Ring programming language version 1.5.4 book - Part 15 of 185
The Ring programming language version 1.5.4 book - Part 15 of 185The Ring programming language version 1.5.4 book - Part 15 of 185
The Ring programming language version 1.5.4 book - Part 15 of 185Mahmoud Samir Fayed
 
The Ring programming language version 1.5.2 book - Part 14 of 181
The Ring programming language version 1.5.2 book - Part 14 of 181The Ring programming language version 1.5.2 book - Part 14 of 181
The Ring programming language version 1.5.2 book - Part 14 of 181Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 22 of 212
The Ring programming language version 1.10 book - Part 22 of 212The Ring programming language version 1.10 book - Part 22 of 212
The Ring programming language version 1.10 book - Part 22 of 212Mahmoud Samir Fayed
 
The Ring programming language version 1.5.1 book - Part 13 of 180
The Ring programming language version 1.5.1 book - Part 13 of 180The Ring programming language version 1.5.1 book - Part 13 of 180
The Ring programming language version 1.5.1 book - Part 13 of 180Mahmoud Samir Fayed
 
The Ring programming language version 1.5 book - Part 3 of 31
The Ring programming language version 1.5 book - Part 3 of 31The Ring programming language version 1.5 book - Part 3 of 31
The Ring programming language version 1.5 book - Part 3 of 31Mahmoud Samir Fayed
 
The Ring programming language version 1.3 book - Part 8 of 88
The Ring programming language version 1.3 book - Part 8 of 88The Ring programming language version 1.3 book - Part 8 of 88
The Ring programming language version 1.3 book - Part 8 of 88Mahmoud Samir Fayed
 
The Ring programming language version 1.6 book - Part 184 of 189
The Ring programming language version 1.6 book - Part 184 of 189The Ring programming language version 1.6 book - Part 184 of 189
The Ring programming language version 1.6 book - Part 184 of 189Mahmoud Samir Fayed
 
The Ring programming language version 1.5.3 book - Part 15 of 184
The Ring programming language version 1.5.3 book - Part 15 of 184The Ring programming language version 1.5.3 book - Part 15 of 184
The Ring programming language version 1.5.3 book - Part 15 of 184Mahmoud Samir Fayed
 
The Ring programming language version 1.6 book - Part 16 of 189
The Ring programming language version 1.6 book - Part 16 of 189The Ring programming language version 1.6 book - Part 16 of 189
The Ring programming language version 1.6 book - Part 16 of 189Mahmoud Samir Fayed
 
The Ring programming language version 1.8 book - Part 19 of 202
The Ring programming language version 1.8 book - Part 19 of 202The Ring programming language version 1.8 book - Part 19 of 202
The Ring programming language version 1.8 book - Part 19 of 202Mahmoud Samir Fayed
 
The Ring programming language version 1.7 book - Part 85 of 196
The Ring programming language version 1.7 book - Part 85 of 196The Ring programming language version 1.7 book - Part 85 of 196
The Ring programming language version 1.7 book - Part 85 of 196Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 21 of 212
The Ring programming language version 1.10 book - Part 21 of 212The Ring programming language version 1.10 book - Part 21 of 212
The Ring programming language version 1.10 book - Part 21 of 212Mahmoud Samir Fayed
 
The Ring programming language version 1.5.4 book - Part 14 of 185
The Ring programming language version 1.5.4 book - Part 14 of 185The Ring programming language version 1.5.4 book - Part 14 of 185
The Ring programming language version 1.5.4 book - Part 14 of 185Mahmoud Samir Fayed
 
The Ring programming language version 1.8 book - Part 95 of 202
The Ring programming language version 1.8 book - Part 95 of 202The Ring programming language version 1.8 book - Part 95 of 202
The Ring programming language version 1.8 book - Part 95 of 202Mahmoud Samir Fayed
 
The Ring programming language version 1.5.1 book - Part 71 of 180
The Ring programming language version 1.5.1 book - Part 71 of 180The Ring programming language version 1.5.1 book - Part 71 of 180
The Ring programming language version 1.5.1 book - Part 71 of 180Mahmoud Samir Fayed
 
The Ring programming language version 1.8 book - Part 82 of 202
The Ring programming language version 1.8 book - Part 82 of 202The Ring programming language version 1.8 book - Part 82 of 202
The Ring programming language version 1.8 book - Part 82 of 202Mahmoud Samir Fayed
 
The Ring programming language version 1.7 book - Part 17 of 196
The Ring programming language version 1.7 book - Part 17 of 196The Ring programming language version 1.7 book - Part 17 of 196
The Ring programming language version 1.7 book - Part 17 of 196Mahmoud Samir Fayed
 
The Ring programming language version 1.9 book - Part 21 of 210
The Ring programming language version 1.9 book - Part 21 of 210The Ring programming language version 1.9 book - Part 21 of 210
The Ring programming language version 1.9 book - Part 21 of 210Mahmoud Samir Fayed
 
The Ring programming language version 1.8 book - Part 7 of 202
The Ring programming language version 1.8 book - Part 7 of 202The Ring programming language version 1.8 book - Part 7 of 202
The Ring programming language version 1.8 book - Part 7 of 202Mahmoud Samir Fayed
 

Similar to The Ring programming language version 1.5.3 book - Part 85 of 184 (20)

The Ring programming language version 1.10 book - Part 90 of 212
The Ring programming language version 1.10 book - Part 90 of 212The Ring programming language version 1.10 book - Part 90 of 212
The Ring programming language version 1.10 book - Part 90 of 212
 
The Ring programming language version 1.5.4 book - Part 15 of 185
The Ring programming language version 1.5.4 book - Part 15 of 185The Ring programming language version 1.5.4 book - Part 15 of 185
The Ring programming language version 1.5.4 book - Part 15 of 185
 
The Ring programming language version 1.5.2 book - Part 14 of 181
The Ring programming language version 1.5.2 book - Part 14 of 181The Ring programming language version 1.5.2 book - Part 14 of 181
The Ring programming language version 1.5.2 book - Part 14 of 181
 
The Ring programming language version 1.10 book - Part 22 of 212
The Ring programming language version 1.10 book - Part 22 of 212The Ring programming language version 1.10 book - Part 22 of 212
The Ring programming language version 1.10 book - Part 22 of 212
 
The Ring programming language version 1.5.1 book - Part 13 of 180
The Ring programming language version 1.5.1 book - Part 13 of 180The Ring programming language version 1.5.1 book - Part 13 of 180
The Ring programming language version 1.5.1 book - Part 13 of 180
 
The Ring programming language version 1.5 book - Part 3 of 31
The Ring programming language version 1.5 book - Part 3 of 31The Ring programming language version 1.5 book - Part 3 of 31
The Ring programming language version 1.5 book - Part 3 of 31
 
The Ring programming language version 1.3 book - Part 8 of 88
The Ring programming language version 1.3 book - Part 8 of 88The Ring programming language version 1.3 book - Part 8 of 88
The Ring programming language version 1.3 book - Part 8 of 88
 
The Ring programming language version 1.6 book - Part 184 of 189
The Ring programming language version 1.6 book - Part 184 of 189The Ring programming language version 1.6 book - Part 184 of 189
The Ring programming language version 1.6 book - Part 184 of 189
 
The Ring programming language version 1.5.3 book - Part 15 of 184
The Ring programming language version 1.5.3 book - Part 15 of 184The Ring programming language version 1.5.3 book - Part 15 of 184
The Ring programming language version 1.5.3 book - Part 15 of 184
 
The Ring programming language version 1.6 book - Part 16 of 189
The Ring programming language version 1.6 book - Part 16 of 189The Ring programming language version 1.6 book - Part 16 of 189
The Ring programming language version 1.6 book - Part 16 of 189
 
The Ring programming language version 1.8 book - Part 19 of 202
The Ring programming language version 1.8 book - Part 19 of 202The Ring programming language version 1.8 book - Part 19 of 202
The Ring programming language version 1.8 book - Part 19 of 202
 
The Ring programming language version 1.7 book - Part 85 of 196
The Ring programming language version 1.7 book - Part 85 of 196The Ring programming language version 1.7 book - Part 85 of 196
The Ring programming language version 1.7 book - Part 85 of 196
 
The Ring programming language version 1.10 book - Part 21 of 212
The Ring programming language version 1.10 book - Part 21 of 212The Ring programming language version 1.10 book - Part 21 of 212
The Ring programming language version 1.10 book - Part 21 of 212
 
The Ring programming language version 1.5.4 book - Part 14 of 185
The Ring programming language version 1.5.4 book - Part 14 of 185The Ring programming language version 1.5.4 book - Part 14 of 185
The Ring programming language version 1.5.4 book - Part 14 of 185
 
The Ring programming language version 1.8 book - Part 95 of 202
The Ring programming language version 1.8 book - Part 95 of 202The Ring programming language version 1.8 book - Part 95 of 202
The Ring programming language version 1.8 book - Part 95 of 202
 
The Ring programming language version 1.5.1 book - Part 71 of 180
The Ring programming language version 1.5.1 book - Part 71 of 180The Ring programming language version 1.5.1 book - Part 71 of 180
The Ring programming language version 1.5.1 book - Part 71 of 180
 
The Ring programming language version 1.8 book - Part 82 of 202
The Ring programming language version 1.8 book - Part 82 of 202The Ring programming language version 1.8 book - Part 82 of 202
The Ring programming language version 1.8 book - Part 82 of 202
 
The Ring programming language version 1.7 book - Part 17 of 196
The Ring programming language version 1.7 book - Part 17 of 196The Ring programming language version 1.7 book - Part 17 of 196
The Ring programming language version 1.7 book - Part 17 of 196
 
The Ring programming language version 1.9 book - Part 21 of 210
The Ring programming language version 1.9 book - Part 21 of 210The Ring programming language version 1.9 book - Part 21 of 210
The Ring programming language version 1.9 book - Part 21 of 210
 
The Ring programming language version 1.8 book - Part 7 of 202
The Ring programming language version 1.8 book - Part 7 of 202The Ring programming language version 1.8 book - Part 7 of 202
The Ring programming language version 1.8 book - Part 7 of 202
 

More from Mahmoud Samir Fayed

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 212Mahmoud Samir Fayed
 
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 212Mahmoud Samir Fayed
 
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 212Mahmoud Samir Fayed
 
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 212Mahmoud Samir Fayed
 
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 212Mahmoud Samir Fayed
 
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 212Mahmoud Samir Fayed
 
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 212Mahmoud Samir Fayed
 
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 212Mahmoud Samir Fayed
 
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 212Mahmoud Samir Fayed
 
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 212Mahmoud Samir Fayed
 
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 212Mahmoud Samir Fayed
 
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 212Mahmoud Samir Fayed
 
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 212Mahmoud Samir Fayed
 
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 212Mahmoud Samir Fayed
 
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 212Mahmoud Samir Fayed
 
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 212Mahmoud Samir Fayed
 
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 212Mahmoud Samir Fayed
 
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 212Mahmoud Samir Fayed
 
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 212Mahmoud Samir Fayed
 
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 212Mahmoud 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

Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsAndrey Dotsenko
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfngoud9212
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 

Recently uploaded (20)

Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdf
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 

The Ring programming language version 1.5.3 book - Part 85 of 184

  • 1. Ring Documentation, Release 1.5.3 x = 1 / 0 catch see "catching error" + nl } Output: if statement.. one for loop.. 12345678910 switch... one try catch... catching error 62.11 Using ‘put’ and ‘get’ as ‘see’ and ‘give’ We can replace the ‘see’ keyword with the ‘put’ keyword. Also we can replacew the ‘give’ keyword with the ‘get’ keyword. Example: put "Hello World" + nl put "Enter Your Name ? " Get Name Put "Hello " + Name 62.12 Using ‘case’ as ‘on’ in switch statements We can replace the ‘on’ keyword with ‘case’ keyword in the switch statement. Example (1) : for x=1 to 10 switch x case 1 put "one" + nl case 2 put "two" + nl case 3 put "thre" + nl else put "else" + nl end end Example (2) : for x=1 to 10 { switch x { case 1 put "one" + nl case 2 put "two" + nl case 3 put "thre" + nl else put "else" + nl } } 62.11. Using ‘put’ and ‘get’ as ‘see’ and ‘give’ 715
  • 2. Ring Documentation, Release 1.5.3 62.13 Using ‘def’ as ‘func’ in functions/methods definition We can use the ‘def’ keyword as the ‘func’ keyword to define functions and methods. Example: one() two() def one put "one" + nl def two put "two" + nl 62.14 Using braces { } in Packages/Classes/Functions Example: load "stdlib.ring" import mypackage new myclass { myfunc() } package mypackage { class myclass { func myfunc { print("Hello, World!n") } } } 62.15 Using ‘end’ keyword after Packages/Classes/Functions Example: import mypackage new myclass { myfunc() } package mypackage class myclass def myfunc put "Hello, World!" end end end 62.13. Using ‘def’ as ‘func’ in functions/methods definition 716
  • 3. Ring Documentation, Release 1.5.3 62.16 Using ‘endpackage’/’endclass’/’endfunc’ keywords after Pack- ages/Classes/Functions Example: import mypackage new myclass { myfunc() } package mypackage class myclass func myfunc see "welcome" + nl endfunc endclass endpackage 62.16. Using ‘endpackage’/’endclass’/’endfunc’ keywords after Packages/Classes/Functions 717
  • 4. CHAPTER SIXTYTHREE INTRODUCTION TO THE TYPE HINTS LIBRARY In this chapter we will learn about the Type Hints Library 63.1 Why Type Hints? Using this library we can add the type information to the source code which will be very useful for tools like • Code Editors • Static-Analysis Note: Ring is a dynamic language, No type checking will be done by the compiler. 63.2 Example The next example will use the Type Hints library load "typehints.ring" see sum(3,4) + nl ; see sayHello("Mahmoud"); int func sum(int x,int y) { return x+y ; } string func sayHello(string name) { return "Hello " + name ; } 63.3 User Types The Type Hints library is very powerful and will support user types (Classes) automatically Example: load "typehints.ring" import mypackage 718
  • 5. Ring Documentation, Release 1.5.3 test() { main([:one,:two,:three]) } myclass func test() { see "Testing User Types!" + nl return new myclass } package mypackage { public class myclass { public static void func main(list args) { see "welcome" + nl see args } } } 63.4 Using Types inside Code Also you can use the types inside the code (not only the function prototype) Example: load "typehints.ring" int sum = sum(3,4) string msg = sayHello("Mahmoud") see "Sum = " + sum + nl + msg + nl int func sum(int x,int y) { return x+y ; } string func sayHello(string name) { return "Hello " + name ; } 63.5 Rules • To use the types in the function prototype you must use ‘(‘ and ‘)’ around parameters • To use the types in the function code, You must set the variable value (Assignment). The next types are defined by the library # Low Level Types char unsigned signed int short long float 63.4. Using Types inside Code 719
  • 6. Ring Documentation, Release 1.5.3 double void # High Level Types string list number object # Other public static abstract protected override 63.5. Rules 720
  • 7. CHAPTER SIXTYFOUR DISTRIBUTING RING APPLICATIONS In this chapter we will learn about distributing Ring applications. 64.1 Distributing Applications for Microsoft Windows Step 1: Copy c:ringbin folder to be for example c:myapp Step 2: Rename c:myappring.exe to c:myappmyapp.exe Step 3: Create a file c:myappring.ring And write Load "myapp.ring" When you run myapp.exe the file ring.ring will be executed automatically So your file myapp.ring will be called and executed Or just rename myapp.ring to ring.ring It’s a fast way to distribute applications. 64.2 Protecting the Source Code Step 1: Execute the next command ring myapp.ring -go This will generate one object file (myapp.ringo) from the project files (*.ring) Step 2: Rename myapp.ringo to ring.ringo When you run the executable file (ring.exe) or (myapp.exe) the file ring.ringo will be executed. 721
  • 8. Ring Documentation, Release 1.5.3 64.3 Creating Windows Installer There are many tools that you can use to distribute your application. Check : nullsoft scriptable install system URL : http://nsis.sourceforge.net/Main_Page 64.4 Using C/C++ Compiler and Linker Another method to distribute applications is to use a C/C++ compiler. Ring can be embedded in C/C++ projects, We can create executable files using a C/C++ compiler by embedding the Ring language in our project. Check the “Embedding Ring Language in C/C++ Programs” chapter. Using this way we will avoid using ring.ring or ring.ringo files. 64.5 Distributing Applications and Games for Mobile Ring can be embedded in a Qt projects or LibSDL projects to build Mobile applications and Games. You can build the Qt project or the LibSDL project and get the Android package directly (*.apk) Check Ring distributions for Mobile development using Qt or LibSDL. 64.3. Creating Windows Installer 722
  • 9. CHAPTER SIXTYFIVE COMMAND LINE OPTIONS The ring language takes source code file (.ring) or the object file (.ringo) as input to execute, also the language provide other options like Option Description -tokens Print a list of tokens in the source code file -rules Print grammar rules applied on the tokens -ic Print the intermediate byte code (before execution) -icfinal Print the final byte code (after execution) -cgi Print http response header before error messages -norun Don’t run the program after compiling -ins Print instruction operation code before execution -performance Print clock before and after program execution -go Generate Object File -w Display Warnings 65.1 Printing Tokens Example: Func Main See "Hello World" + nl for x = 1 to 10 see x + nl next test() func test see "welcome" + nl o1 = new point { x=10 y=20 z=30 } see o1 class point x y z Command: ring test.ring -tokens -norun Output: =================================================== Tokens - Generated by the Scanner =================================================== 723
  • 10. Ring Documentation, Release 1.5.3 Keyword : FUNC Identifier : main EndLine Keyword : SEE Literal : Hello World Operator : + Identifier : nl EndLine Keyword : FOR Identifier : x Operator : = Number : 1 Keyword : TO Number : 10 EndLine Keyword : SEE Identifier : x Operator : + Identifier : nl EndLine Keyword : NEXT EndLine Identifier : test Operator : ( Operator : ) EndLine Keyword : FUNC Identifier : test EndLine Keyword : SEE Literal : welcome Operator : + Identifier : nl EndLine Identifier : o1 Operator : = Keyword : NEW Identifier : point Operator : { Identifier : x Operator : = Number : 10 Identifier : y Operator : = Number : 20 Identifier : z Operator : = Number : 30 Operator : } EndLine Keyword : SEE Identifier : o1 EndLine Keyword : CLASS Identifier : point Identifier : x Identifier : y Identifier : z 65.1. Printing Tokens 724