SlideShare une entreprise Scribd logo
1  sur  10
Télécharger pour lire hors ligne
Ring Documentation
Release 1.3
Eng. Mahmoud Fayed and Dr. Atif Alamri
May 15, 2017
CONTENTS
1 Applications developed in little hours 1
1.1 Quotes about Ring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 FetchStockData Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3 Fifteen Puzzle Game . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.4 TicTacToe Game . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.5 Squares Puzzle Game . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.6 Werdy Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.7 Samples in this book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2 Introduction 9
2.1 Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.2 History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.3 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.4 License . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3 Language Design 14
3.1 Why Ring? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.2 Designed for a Clear Goal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.3 Simple . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.4 Trying to be natural . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.5 Encourage Organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
3.6 Transparent Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
3.7 Visual Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.8 Compact Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
3.9 Define Natural Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.10 Define Declarative Languages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
3.11 Smart Garbage Collector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
4 What is new in Ring 1.3? 23
4.1 List of changes and new features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
4.2 Better RingQt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
4.3 Better Ring Notepad . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
4.4 Ring mode for Emacs Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
4.5 Better StdLib . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
4.6 Better Loop|Exit Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
4.7 New Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
4.8 Return Self by Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
4.9 Using ‘<’ and ‘:’ operators as ‘from’ keyword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
4.10 Embedding Ring in Ring without sharing the State . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
4.11 RingZip Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
4.12 Form Designer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
i
5 What is new in Ring 1.2? 36
5.1 List of changes and new features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
5.2 New Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
5.3 Better Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
5.4 Better Ring Notepad . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
5.5 Better RingQt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
5.6 Objects Library for RingQt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
5.7 RingLibCurl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
5.8 Better Call Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
5.9 Using NULL instead of NULLPointer() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
5.10 Display Warnings Option . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
5.11 Better Quality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
6 What is new in Ring 1.1? 42
6.1 List of changes and new features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
6.2 Better Natural Language Programming Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
6.3 Generate/Execute Ring Object Files (*.ringo) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
6.4 Syntax Flexibility and different styles for I/O and Control Structures . . . . . . . . . . . . . . . . . . 43
6.5 New Functions and Changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
6.6 StdLib functions and classes written in Ring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
6.7 RingLibSDL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
6.8 Demo Project - Game Engine for 2D Games . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
6.9 RingSQLite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
6.10 Better Code Generator for Extensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
6.11 Using Self.Attribute in the Class Region to define new attributes . . . . . . . . . . . . . . . . . . . . 50
6.12 Using This.Attribute in nested Braces inside the Class Methods . . . . . . . . . . . . . . . . . . . . 50
6.13 Better Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
7 Building From Source Code 52
7.1 Building using Microsoft Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
7.2 Building using Ubuntu Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
7.3 Building using MacOS X . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
7.4 Building using CMake . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
8 How to contribute? 56
8.1 Special thanks to contributors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
8.2 Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
8.3 Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
8.4 Samples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
8.5 Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
8.6 Editors Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
8.7 Libraries in Ring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
8.8 Extensions in C/C++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
8.9 Compiler and Virtual Machine (VM) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
8.10 Ideas and suggestions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
9 Getting Started - First Style 58
9.1 Hello World . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
9.2 Run the program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
9.3 Not Case-Sensitive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
9.4 Multi-Line literals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
9.5 Getting Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
9.6 No Explicit End For Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
9.7 Writing Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
ii
10 Getting Started - Second Style 60
10.1 Hello World . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
10.2 Run the program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
10.3 Not Case-Sensitive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
10.4 Multi-Line literals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
10.5 Getting Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
10.6 No Explicit End For Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
10.7 Writing Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
11 Getting Started - Third Style 62
11.1 Hello World . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
11.2 Run the program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
11.3 Not Case-Sensitive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
11.4 Multi-Line literals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
11.5 Getting Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
11.6 No Explicit End For Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
11.7 Writing Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
12 Using Ring Notepad 64
12.1 Ring Notepad - Main Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
12.2 Creating and running your first Console Application . . . . . . . . . . . . . . . . . . . . . . . . . . 65
12.3 Creating and running your first GUI/Mobile Application . . . . . . . . . . . . . . . . . . . . . . . . 67
12.4 Creating and running your first Web Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
12.5 Creating and running your first Desktop/Mobile Game . . . . . . . . . . . . . . . . . . . . . . . . . 69
13 Using Other Code Editors 71
13.1 Using Notepad++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
13.2 Using Geany . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
13.3 Using Atom . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
13.4 Using Sublime Text 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
13.5 Using Visual Studio IDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
13.6 Using Emacs Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
14 Variables 77
14.1 Dynamic Typing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
14.2 Deep Copy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
14.3 Weakly Typed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
15 Operators 79
15.1 Arithmetic Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
15.2 Relational Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
15.3 Logical Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
15.4 Bitwise Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
15.5 Assignment Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
15.6 Misc Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
15.7 Operators Precedence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
16 Control Structures - First Style 82
16.1 Branching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
16.2 Looping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
16.3 Using The Step option with For in . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
16.4 Using For in to modify lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
16.5 Do Again Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
16.6 Exit Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
16.7 Exit from two loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
iii
16.8 Exit/Loop inside sub functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
16.9 Short-circuit evaluation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
16.10 Comments about evaluation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
17 Control Structures - Second Style 89
17.1 Branching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
17.2 Looping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
17.3 Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
18 Control Structures - Third Style 92
18.1 Branching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
18.2 Looping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
18.3 Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
19 Getting Input 97
19.1 Give Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
19.2 GetChar() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
19.3 Input() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
20 Functions 99
20.1 Define Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
20.2 Call Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
20.3 Declare parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
20.4 Send Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
20.5 Main Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
20.6 Variables Scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
20.7 Return Value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
20.8 Recursion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
21 Program Structure 103
21.1 Source Code File Sections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
21.2 Using Many Source Code Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
22 Lists 104
22.1 Create Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
22.2 Add Items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
22.3 Get List Size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
22.4 Delete Item From List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
22.5 Get List Item . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
22.6 Set List Item . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
22.7 Search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
22.8 Sort . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
22.9 Reverse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
22.10 Insert Items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
22.11 Nested Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
22.12 Copy Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
22.13 First-class lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
22.14 Using Lists during definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
22.15 Passing Lists to Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
22.16 Access List Items by String Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
22.17 Passing Parameters Using List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
22.18 Swap Items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
23 Strings 112
23.1 String Literals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
iv
23.2 Get String Length . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
23.3 Convert Letters Case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
23.4 Access String Letters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
23.5 Left() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
23.6 Right() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
23.7 Trim() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
23.8 Copy() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
23.9 Lines() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
23.10 Substr() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
23.11 Find substring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
23.12 Get substring from position to end . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
23.13 Get Number of Characters From Position . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
23.14 Transform Substring To Another Substring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
23.15 strcmp() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
23.16 str2list() and list2str() Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
24 Date and Time 118
24.1 Clock() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
24.2 ClocksPerSecond() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
24.3 Time() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
24.4 Date() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
24.5 TimeList() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
24.6 AddDays() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
24.7 DiffDays() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
25 Check Data Type and Conversion 121
25.1 Check Data Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
25.2 IsString() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
25.3 IsNumber() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
25.4 IsList() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
25.5 Type() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
25.6 IsNULL() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
25.7 Check Character . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
25.8 IsAlNum() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
25.9 IsAlpha() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
25.10 IsCntrl() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
25.11 IsDigit() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
25.12 IsGraph() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
25.13 IsLower() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
25.14 IsPrint() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
25.15 IsPunct() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
25.16 IsSpace() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
25.17 IsUpper() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
25.18 IsXdigit() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
25.19 Conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
25.20 Number() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
25.21 String() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
25.22 Ascii() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
25.23 Char() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
25.24 Hex() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
25.25 Dec() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
25.26 Str2hex() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
25.27 Hex2str() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
v
26 Mathematical Functions 129
26.1 List of functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
26.2 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
26.3 Random() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
26.4 Unsigned() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
26.5 Decimals() Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
27 Files 134
27.1 Read() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
27.2 Write() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
27.3 Dir() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
27.4 Rename() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
27.5 Remove() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
27.6 Fopen() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
27.7 Fclose() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
27.8 Fflush() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
27.9 Freopen() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
27.10 Tempfile() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
27.11 Tempname() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
27.12 Fseek() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
27.13 Ftell() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
27.14 Rewind() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
27.15 Fgetpos() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
27.16 Fsetpos() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
27.17 Clearerr() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
27.18 Feof() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
27.19 Ferror() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
27.20 Perror() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
27.21 Fgetc() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
27.22 Fgets() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
27.23 Fputc() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
27.24 Fputs() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
27.25 Ungetc() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
27.26 Fread() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
27.27 Fwrite() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
27.28 Fexists() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
27.29 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
28 System Functions 144
28.1 System() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
28.2 SysGet() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
28.3 IsMSDOS() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
28.4 IsWindows() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
28.5 IsWindows64() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
28.6 IsUnix() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
28.7 IsMacOSX() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
28.8 IsLinux() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
28.9 IsFreeBSD() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
28.10 IsAndroid() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
28.11 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
28.12 Windowsnl() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
28.13 Get Command Line Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
28.14 Get Active Source File Name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
28.15 PrevFileName() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
vi
28.16 CurrentDir() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
28.17 ExeFileName() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
28.18 ChDir() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
28.19 ExeFolder() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
28.20 Version() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
29 Eval() and Debugging 150
29.1 Try/Catch/Done . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
29.2 Eval() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
29.3 Raise() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
29.4 Assert() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
30 Demo Programs 153
30.1 Language Shell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
30.2 Main Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
31 ODBC Functions 157
31.1 odbc_init() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
31.2 odbc_drivers() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
31.3 odbc_datasources() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
31.4 odbc_close() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
31.5 Print List of ODBC Drivers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
31.6 Print List of ODBC Data Sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
31.7 odbc_connect() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
31.8 odbc_disconnect() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
31.9 Open and Close Connection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
31.10 odbc_execute() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
31.11 odbc_colcount() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
31.12 odbc_fetch() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
31.13 odbc_getdata() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
31.14 Execute Query and Print Result . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
31.15 odbc_tables() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
31.16 odbc_columns() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
31.17 odbc_autocommit() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
31.18 odbc_commit() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
31.19 odbc_rollback() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
31.20 Transactions and Using Commit and Rollback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
31.21 Save and Restore images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
32 MySQL Functions 166
32.1 MySQL_Info() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
32.2 MySQL_Init() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
32.3 MySQL_Error() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
32.4 MySQL_Connect() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
32.5 MySQL_Close() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
32.6 MySQL_Query() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
32.7 Create Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
32.8 Create Table and Insert Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
32.9 MySQL_Insert_ID() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
32.10 MySQL_Result() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
32.11 MySQL_Next_Result() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
32.12 Print Query Result . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
32.13 MySQL_Columns() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
32.14 MySQL_Result2() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
32.15 MySQL_Escape_String() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
vii
32.16 Save Image inside the database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
32.17 Restore Image From The Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
32.18 MySQL_AutoCommit() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
32.19 MySQL_Commit() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
32.20 MySQL_Rollback() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
32.21 Transaction Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
33 SQLite Functions 175
33.1 sqlite_init() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
33.2 sqlite_open() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
33.3 sqlite_execute() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
33.4 sqlite_close() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
33.5 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
34 Security and Internet Functions 178
34.1 MD5() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
34.2 SHA1() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
34.3 SHA256() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
34.4 SHA512() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
34.5 SHA384() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
34.6 SHA224() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
34.7 Encrypt() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
34.8 Decrypt() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
34.9 Encryption and Decryption Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
34.10 File Hash . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
34.11 Randbytes() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
34.12 Download() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
34.13 SendEmail() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
35 Object Oriented Programming (OOP) 183
35.1 Classes and Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
35.2 Access Objects Using Braces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
35.3 Composition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186
35.4 Setter and Getter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
35.5 Private Attributes and Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
35.6 Operator Overloading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
35.7 Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
35.8 Dynamic Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
35.9 Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
35.10 Printing Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
35.11 Find() and List of Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
35.12 Sort() and list of objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
35.13 Using Self.Attribute and Self.Method() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194
35.14 Using This.Attribute and This.Method() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
36 Functional Programming 196
36.1 Pure Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
36.2 First-class Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
36.3 Higher-order Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
36.4 Anonymous and Nested Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198
36.5 Equality of functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
37 Reflection and Meta-programming 201
37.1 locals() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
37.2 globals() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
viii

Contenu connexe

Tendances

The Ring programming language version 1.9 book - Part 1 of 210
The Ring programming language version 1.9 book - Part 1 of 210The Ring programming language version 1.9 book - Part 1 of 210
The Ring programming language version 1.9 book - Part 1 of 210Mahmoud Samir Fayed
 
The Ring programming language version 1.5.3 book - Part 1 of 184
The Ring programming language version 1.5.3 book - Part 1 of 184The Ring programming language version 1.5.3 book - Part 1 of 184
The Ring programming language version 1.5.3 book - Part 1 of 184Mahmoud Samir Fayed
 
The Ring programming language version 1.5.1 book - Part 1 of 180
The Ring programming language version 1.5.1 book - Part 1 of 180The Ring programming language version 1.5.1 book - Part 1 of 180
The Ring programming language version 1.5.1 book - Part 1 of 180Mahmoud Samir Fayed
 
The Ring programming language version 1.5.4 book - Part 1 of 185
The Ring programming language version 1.5.4 book - Part 1 of 185The Ring programming language version 1.5.4 book - Part 1 of 185
The Ring programming language version 1.5.4 book - Part 1 of 185Mahmoud Samir Fayed
 
Support formation vidéo : Excel 2016 - Maîtrisez les bases
Support formation vidéo : Excel 2016 - Maîtrisez les basesSupport formation vidéo : Excel 2016 - Maîtrisez les bases
Support formation vidéo : Excel 2016 - Maîtrisez les basesSmartnSkilled
 
initiation-au-langage-c-et-exercices-corriges
initiation-au-langage-c-et-exercices-corrigesinitiation-au-langage-c-et-exercices-corriges
initiation-au-langage-c-et-exercices-corrigesjojo sekkat
 
Lavorare con java 6
Lavorare con java 6Lavorare con java 6
Lavorare con java 6Pi Libri
 
La base de données Oracle
La base de données OracleLa base de données Oracle
La base de données OracleBruno Delb
 
The Ring programming language version 1.9 book - Part 3 of 210
The Ring programming language version 1.9 book - Part 3 of 210The Ring programming language version 1.9 book - Part 3 of 210
The Ring programming language version 1.9 book - Part 3 of 210Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 3 of 212
The Ring programming language version 1.10 book - Part 3 of 212The Ring programming language version 1.10 book - Part 3 of 212
The Ring programming language version 1.10 book - Part 3 of 212Mahmoud Samir Fayed
 
Eripm wd bgt0000 nbk
Eripm wd bgt0000 nbkEripm wd bgt0000 nbk
Eripm wd bgt0000 nbkSprl Eripm
 

Tendances (20)

The Ring programming language version 1.9 book - Part 1 of 210
The Ring programming language version 1.9 book - Part 1 of 210The Ring programming language version 1.9 book - Part 1 of 210
The Ring programming language version 1.9 book - Part 1 of 210
 
The Ring programming language version 1.5.3 book - Part 1 of 184
The Ring programming language version 1.5.3 book - Part 1 of 184The Ring programming language version 1.5.3 book - Part 1 of 184
The Ring programming language version 1.5.3 book - Part 1 of 184
 
The Ring programming language version 1.5.1 book - Part 1 of 180
The Ring programming language version 1.5.1 book - Part 1 of 180The Ring programming language version 1.5.1 book - Part 1 of 180
The Ring programming language version 1.5.1 book - Part 1 of 180
 
The Ring programming language version 1.5.4 book - Part 1 of 185
The Ring programming language version 1.5.4 book - Part 1 of 185The Ring programming language version 1.5.4 book - Part 1 of 185
The Ring programming language version 1.5.4 book - Part 1 of 185
 
Deviens un Ninja avec Angular2
Deviens un Ninja avec Angular2Deviens un Ninja avec Angular2
Deviens un Ninja avec Angular2
 
Support formation vidéo : Excel 2016 - Maîtrisez les bases
Support formation vidéo : Excel 2016 - Maîtrisez les basesSupport formation vidéo : Excel 2016 - Maîtrisez les bases
Support formation vidéo : Excel 2016 - Maîtrisez les bases
 
initiation-au-langage-c-et-exercices-corriges
initiation-au-langage-c-et-exercices-corrigesinitiation-au-langage-c-et-exercices-corriges
initiation-au-langage-c-et-exercices-corriges
 
Lavorare con java 6
Lavorare con java 6Lavorare con java 6
Lavorare con java 6
 
La base de données Oracle
La base de données OracleLa base de données Oracle
La base de données Oracle
 
Oracle 11g exploitation
Oracle 11g exploitationOracle 11g exploitation
Oracle 11g exploitation
 
Tp sgbd gsi
Tp sgbd gsiTp sgbd gsi
Tp sgbd gsi
 
The Ring programming language version 1.9 book - Part 3 of 210
The Ring programming language version 1.9 book - Part 3 of 210The Ring programming language version 1.9 book - Part 3 of 210
The Ring programming language version 1.9 book - Part 3 of 210
 
Guide latex.
Guide latex.Guide latex.
Guide latex.
 
Programmation en-java-api
Programmation en-java-apiProgrammation en-java-api
Programmation en-java-api
 
The Ring programming language version 1.10 book - Part 3 of 212
The Ring programming language version 1.10 book - Part 3 of 212The Ring programming language version 1.10 book - Part 3 of 212
The Ring programming language version 1.10 book - Part 3 of 212
 
Eripm wd bgt0000 nbk
Eripm wd bgt0000 nbkEripm wd bgt0000 nbk
Eripm wd bgt0000 nbk
 
Access 2007
Access 2007Access 2007
Access 2007
 
Cbdsys 2
Cbdsys 2Cbdsys 2
Cbdsys 2
 
Analyse numérique
Analyse numériqueAnalyse numérique
Analyse numérique
 
Complet
CompletComplet
Complet
 

Similaire à The Ring programming language version 1.3 book - Part 1 of 88

Base-de-données.pdf
Base-de-données.pdfBase-de-données.pdf
Base-de-données.pdfdjallel2
 
courspython3.pdf
courspython3.pdfcourspython3.pdf
courspython3.pdfDendouga1
 
Rapport de projet_de_fin_d__tudes__pfe__safwen (8)
Rapport de projet_de_fin_d__tudes__pfe__safwen (8)Rapport de projet_de_fin_d__tudes__pfe__safwen (8)
Rapport de projet_de_fin_d__tudes__pfe__safwen (8)safwenbenfredj
 
Rapport Projet De Fin D'étude de Conception et développement d’une applicatio...
Rapport Projet De Fin D'étude de Conception et développement d’une applicatio...Rapport Projet De Fin D'étude de Conception et développement d’une applicatio...
Rapport Projet De Fin D'étude de Conception et développement d’une applicatio...mouafekmazia
 
Manuel du module additionnel RF-LAMINATE pour RFEM
Manuel du module additionnel RF-LAMINATE pour RFEMManuel du module additionnel RF-LAMINATE pour RFEM
Manuel du module additionnel RF-LAMINATE pour RFEMGrégoire Dupont
 
Ibm spectrum archive enterprise edition
Ibm spectrum archive enterprise editionIbm spectrum archive enterprise edition
Ibm spectrum archive enterprise editionLuciano Saia
 
The Ring programming language version 1.8 book - Part 3 of 202
The Ring programming language version 1.8 book - Part 3 of 202The Ring programming language version 1.8 book - Part 3 of 202
The Ring programming language version 1.8 book - Part 3 of 202Mahmoud Samir Fayed
 
9783642290435 t1
9783642290435 t19783642290435 t1
9783642290435 t1nenena1976
 
Apache Web Server Index
Apache Web Server IndexApache Web Server Index
Apache Web Server Indexwebhostingguy
 
Introduction á C-sharp
Introduction á C-sharpIntroduction á C-sharp
Introduction á C-sharpmedfa
 
réaliser une plateforme d’automatisation et de génération des rapports de test
réaliser une plateforme d’automatisation et de génération des rapports de testréaliser une plateforme d’automatisation et de génération des rapports de test
réaliser une plateforme d’automatisation et de génération des rapports de testahmed oumezzine
 
Deep Learning : Application à la reconnaissance d’objets de classes multiples...
Deep Learning : Application à la reconnaissance d’objets de classes multiples...Deep Learning : Application à la reconnaissance d’objets de classes multiples...
Deep Learning : Application à la reconnaissance d’objets de classes multiples...Haytam EL YOUSSFI
 
Description open erp_v_7
Description open erp_v_7Description open erp_v_7
Description open erp_v_7Ab Rafaoui
 
Mémoire fin d'étude gestion des interventions
Mémoire fin d'étude gestion des interventionsMémoire fin d'étude gestion des interventions
Mémoire fin d'étude gestion des interventionsMohamed Arar
 

Similaire à The Ring programming language version 1.3 book - Part 1 of 88 (18)

Base-de-données.pdf
Base-de-données.pdfBase-de-données.pdf
Base-de-données.pdf
 
cours_python.pdf
cours_python.pdfcours_python.pdf
cours_python.pdf
 
courspython3.pdf
courspython3.pdfcourspython3.pdf
courspython3.pdf
 
Rapport de projet_de_fin_d__tudes__pfe__safwen (8)
Rapport de projet_de_fin_d__tudes__pfe__safwen (8)Rapport de projet_de_fin_d__tudes__pfe__safwen (8)
Rapport de projet_de_fin_d__tudes__pfe__safwen (8)
 
Rapport Projet De Fin D'étude de Conception et développement d’une applicatio...
Rapport Projet De Fin D'étude de Conception et développement d’une applicatio...Rapport Projet De Fin D'étude de Conception et développement d’une applicatio...
Rapport Projet De Fin D'étude de Conception et développement d’une applicatio...
 
Manuel du module additionnel RF-LAMINATE pour RFEM
Manuel du module additionnel RF-LAMINATE pour RFEMManuel du module additionnel RF-LAMINATE pour RFEM
Manuel du module additionnel RF-LAMINATE pour RFEM
 
Poly
PolyPoly
Poly
 
Ibm spectrum archive enterprise edition
Ibm spectrum archive enterprise editionIbm spectrum archive enterprise edition
Ibm spectrum archive enterprise edition
 
The Ring programming language version 1.8 book - Part 3 of 202
The Ring programming language version 1.8 book - Part 3 of 202The Ring programming language version 1.8 book - Part 3 of 202
The Ring programming language version 1.8 book - Part 3 of 202
 
9783642290435 t1
9783642290435 t19783642290435 t1
9783642290435 t1
 
Apache Web Server Index
Apache Web Server IndexApache Web Server Index
Apache Web Server Index
 
rapport_stage_TBLB.pdf
rapport_stage_TBLB.pdfrapport_stage_TBLB.pdf
rapport_stage_TBLB.pdf
 
Algo
AlgoAlgo
Algo
 
Introduction á C-sharp
Introduction á C-sharpIntroduction á C-sharp
Introduction á C-sharp
 
réaliser une plateforme d’automatisation et de génération des rapports de test
réaliser une plateforme d’automatisation et de génération des rapports de testréaliser une plateforme d’automatisation et de génération des rapports de test
réaliser une plateforme d’automatisation et de génération des rapports de test
 
Deep Learning : Application à la reconnaissance d’objets de classes multiples...
Deep Learning : Application à la reconnaissance d’objets de classes multiples...Deep Learning : Application à la reconnaissance d’objets de classes multiples...
Deep Learning : Application à la reconnaissance d’objets de classes multiples...
 
Description open erp_v_7
Description open erp_v_7Description open erp_v_7
Description open erp_v_7
 
Mémoire fin d'étude gestion des interventions
Mémoire fin d'étude gestion des interventionsMémoire fin d'étude gestion des interventions
Mémoire fin d'étude gestion des interventions
 

Plus de 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
 

Plus de 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
 

The Ring programming language version 1.3 book - Part 1 of 88

  • 1.
  • 2. Ring Documentation Release 1.3 Eng. Mahmoud Fayed and Dr. Atif Alamri May 15, 2017
  • 3. CONTENTS 1 Applications developed in little hours 1 1.1 Quotes about Ring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.2 FetchStockData Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1.3 Fifteen Puzzle Game . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 1.4 TicTacToe Game . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 1.5 Squares Puzzle Game . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 1.6 Werdy Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 1.7 Samples in this book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 2 Introduction 9 2.1 Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 2.2 History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 2.3 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 2.4 License . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 3 Language Design 14 3.1 Why Ring? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 3.2 Designed for a Clear Goal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 3.3 Simple . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 3.4 Trying to be natural . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 3.5 Encourage Organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 3.6 Transparent Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 3.7 Visual Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 3.8 Compact Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 3.9 Define Natural Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 3.10 Define Declarative Languages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 3.11 Smart Garbage Collector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 4 What is new in Ring 1.3? 23 4.1 List of changes and new features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 4.2 Better RingQt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 4.3 Better Ring Notepad . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 4.4 Ring mode for Emacs Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 4.5 Better StdLib . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 4.6 Better Loop|Exit Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 4.7 New Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 4.8 Return Self by Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 4.9 Using ‘<’ and ‘:’ operators as ‘from’ keyword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 4.10 Embedding Ring in Ring without sharing the State . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 4.11 RingZip Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 4.12 Form Designer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 i
  • 4. 5 What is new in Ring 1.2? 36 5.1 List of changes and new features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 5.2 New Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 5.3 Better Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 5.4 Better Ring Notepad . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 5.5 Better RingQt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 5.6 Objects Library for RingQt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 5.7 RingLibCurl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 5.8 Better Call Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 5.9 Using NULL instead of NULLPointer() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 5.10 Display Warnings Option . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 5.11 Better Quality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 6 What is new in Ring 1.1? 42 6.1 List of changes and new features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 6.2 Better Natural Language Programming Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 6.3 Generate/Execute Ring Object Files (*.ringo) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 6.4 Syntax Flexibility and different styles for I/O and Control Structures . . . . . . . . . . . . . . . . . . 43 6.5 New Functions and Changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 6.6 StdLib functions and classes written in Ring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 6.7 RingLibSDL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 6.8 Demo Project - Game Engine for 2D Games . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 6.9 RingSQLite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 6.10 Better Code Generator for Extensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 6.11 Using Self.Attribute in the Class Region to define new attributes . . . . . . . . . . . . . . . . . . . . 50 6.12 Using This.Attribute in nested Braces inside the Class Methods . . . . . . . . . . . . . . . . . . . . 50 6.13 Better Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 7 Building From Source Code 52 7.1 Building using Microsoft Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 7.2 Building using Ubuntu Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 7.3 Building using MacOS X . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 7.4 Building using CMake . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 8 How to contribute? 56 8.1 Special thanks to contributors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 8.2 Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 8.3 Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 8.4 Samples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 8.5 Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 8.6 Editors Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 8.7 Libraries in Ring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 8.8 Extensions in C/C++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 8.9 Compiler and Virtual Machine (VM) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 8.10 Ideas and suggestions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 9 Getting Started - First Style 58 9.1 Hello World . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 9.2 Run the program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 9.3 Not Case-Sensitive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 9.4 Multi-Line literals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 9.5 Getting Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 9.6 No Explicit End For Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 9.7 Writing Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 ii
  • 5. 10 Getting Started - Second Style 60 10.1 Hello World . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 10.2 Run the program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 10.3 Not Case-Sensitive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 10.4 Multi-Line literals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 10.5 Getting Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 10.6 No Explicit End For Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 10.7 Writing Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 11 Getting Started - Third Style 62 11.1 Hello World . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 11.2 Run the program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 11.3 Not Case-Sensitive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 11.4 Multi-Line literals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 11.5 Getting Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 11.6 No Explicit End For Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 11.7 Writing Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 12 Using Ring Notepad 64 12.1 Ring Notepad - Main Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 12.2 Creating and running your first Console Application . . . . . . . . . . . . . . . . . . . . . . . . . . 65 12.3 Creating and running your first GUI/Mobile Application . . . . . . . . . . . . . . . . . . . . . . . . 67 12.4 Creating and running your first Web Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 12.5 Creating and running your first Desktop/Mobile Game . . . . . . . . . . . . . . . . . . . . . . . . . 69 13 Using Other Code Editors 71 13.1 Using Notepad++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 13.2 Using Geany . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 13.3 Using Atom . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 13.4 Using Sublime Text 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 13.5 Using Visual Studio IDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 13.6 Using Emacs Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 14 Variables 77 14.1 Dynamic Typing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 14.2 Deep Copy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 14.3 Weakly Typed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 15 Operators 79 15.1 Arithmetic Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 15.2 Relational Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 15.3 Logical Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 15.4 Bitwise Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 15.5 Assignment Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 15.6 Misc Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 15.7 Operators Precedence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 16 Control Structures - First Style 82 16.1 Branching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 16.2 Looping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 16.3 Using The Step option with For in . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84 16.4 Using For in to modify lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 16.5 Do Again Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 16.6 Exit Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 16.7 Exit from two loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 iii
  • 6. 16.8 Exit/Loop inside sub functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 16.9 Short-circuit evaluation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 16.10 Comments about evaluation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 17 Control Structures - Second Style 89 17.1 Branching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 17.2 Looping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 17.3 Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 18 Control Structures - Third Style 92 18.1 Branching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92 18.2 Looping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 18.3 Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 19 Getting Input 97 19.1 Give Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 19.2 GetChar() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 19.3 Input() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 20 Functions 99 20.1 Define Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 20.2 Call Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 20.3 Declare parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 20.4 Send Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 20.5 Main Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 20.6 Variables Scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 20.7 Return Value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 20.8 Recursion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102 21 Program Structure 103 21.1 Source Code File Sections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 21.2 Using Many Source Code Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 22 Lists 104 22.1 Create Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104 22.2 Add Items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104 22.3 Get List Size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 22.4 Delete Item From List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 22.5 Get List Item . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 22.6 Set List Item . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 22.7 Search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 22.8 Sort . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 22.9 Reverse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 22.10 Insert Items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 22.11 Nested Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 22.12 Copy Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 22.13 First-class lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 22.14 Using Lists during definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 22.15 Passing Lists to Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 22.16 Access List Items by String Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 22.17 Passing Parameters Using List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 22.18 Swap Items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111 23 Strings 112 23.1 String Literals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 iv
  • 7. 23.2 Get String Length . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 23.3 Convert Letters Case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 23.4 Access String Letters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 23.5 Left() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 23.6 Right() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 23.7 Trim() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 23.8 Copy() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 23.9 Lines() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 23.10 Substr() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 23.11 Find substring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 23.12 Get substring from position to end . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 23.13 Get Number of Characters From Position . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 23.14 Transform Substring To Another Substring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 23.15 strcmp() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 23.16 str2list() and list2str() Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 24 Date and Time 118 24.1 Clock() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 24.2 ClocksPerSecond() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 24.3 Time() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 24.4 Date() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 24.5 TimeList() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 24.6 AddDays() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120 24.7 DiffDays() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120 25 Check Data Type and Conversion 121 25.1 Check Data Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 25.2 IsString() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 25.3 IsNumber() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 25.4 IsList() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 25.5 Type() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 25.6 IsNULL() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 25.7 Check Character . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 25.8 IsAlNum() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 25.9 IsAlpha() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 25.10 IsCntrl() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124 25.11 IsDigit() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124 25.12 IsGraph() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124 25.13 IsLower() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124 25.14 IsPrint() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 25.15 IsPunct() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 25.16 IsSpace() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 25.17 IsUpper() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 25.18 IsXdigit() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126 25.19 Conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126 25.20 Number() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126 25.21 String() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126 25.22 Ascii() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127 25.23 Char() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127 25.24 Hex() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127 25.25 Dec() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127 25.26 Str2hex() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128 25.27 Hex2str() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128 v
  • 8. 26 Mathematical Functions 129 26.1 List of functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 26.2 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 26.3 Random() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131 26.4 Unsigned() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132 26.5 Decimals() Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132 27 Files 134 27.1 Read() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 27.2 Write() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 27.3 Dir() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 27.4 Rename() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136 27.5 Remove() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136 27.6 Fopen() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136 27.7 Fclose() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137 27.8 Fflush() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137 27.9 Freopen() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137 27.10 Tempfile() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 27.11 Tempname() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 27.12 Fseek() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 27.13 Ftell() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 27.14 Rewind() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 27.15 Fgetpos() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 27.16 Fsetpos() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 27.17 Clearerr() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 27.18 Feof() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 27.19 Ferror() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 27.20 Perror() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 27.21 Fgetc() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 27.22 Fgets() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 27.23 Fputc() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 27.24 Fputs() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 27.25 Ungetc() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 27.26 Fread() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141 27.27 Fwrite() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141 27.28 Fexists() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141 27.29 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141 28 System Functions 144 28.1 System() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144 28.2 SysGet() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145 28.3 IsMSDOS() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145 28.4 IsWindows() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145 28.5 IsWindows64() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145 28.6 IsUnix() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145 28.7 IsMacOSX() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145 28.8 IsLinux() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146 28.9 IsFreeBSD() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146 28.10 IsAndroid() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146 28.11 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146 28.12 Windowsnl() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147 28.13 Get Command Line Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147 28.14 Get Active Source File Name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148 28.15 PrevFileName() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148 vi
  • 9. 28.16 CurrentDir() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149 28.17 ExeFileName() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149 28.18 ChDir() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149 28.19 ExeFolder() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149 28.20 Version() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149 29 Eval() and Debugging 150 29.1 Try/Catch/Done . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150 29.2 Eval() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150 29.3 Raise() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151 29.4 Assert() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152 30 Demo Programs 153 30.1 Language Shell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153 30.2 Main Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154 31 ODBC Functions 157 31.1 odbc_init() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 31.2 odbc_drivers() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 31.3 odbc_datasources() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158 31.4 odbc_close() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158 31.5 Print List of ODBC Drivers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158 31.6 Print List of ODBC Data Sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159 31.7 odbc_connect() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159 31.8 odbc_disconnect() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160 31.9 Open and Close Connection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160 31.10 odbc_execute() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160 31.11 odbc_colcount() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160 31.12 odbc_fetch() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161 31.13 odbc_getdata() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161 31.14 Execute Query and Print Result . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161 31.15 odbc_tables() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161 31.16 odbc_columns() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162 31.17 odbc_autocommit() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163 31.18 odbc_commit() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163 31.19 odbc_rollback() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163 31.20 Transactions and Using Commit and Rollback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163 31.21 Save and Restore images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164 32 MySQL Functions 166 32.1 MySQL_Info() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166 32.2 MySQL_Init() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167 32.3 MySQL_Error() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167 32.4 MySQL_Connect() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167 32.5 MySQL_Close() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167 32.6 MySQL_Query() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167 32.7 Create Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167 32.8 Create Table and Insert Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168 32.9 MySQL_Insert_ID() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169 32.10 MySQL_Result() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169 32.11 MySQL_Next_Result() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170 32.12 Print Query Result . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170 32.13 MySQL_Columns() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170 32.14 MySQL_Result2() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171 32.15 MySQL_Escape_String() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172 vii
  • 10. 32.16 Save Image inside the database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172 32.17 Restore Image From The Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172 32.18 MySQL_AutoCommit() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 32.19 MySQL_Commit() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 32.20 MySQL_Rollback() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 32.21 Transaction Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 33 SQLite Functions 175 33.1 sqlite_init() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175 33.2 sqlite_open() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175 33.3 sqlite_execute() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175 33.4 sqlite_close() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175 33.5 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175 34 Security and Internet Functions 178 34.1 MD5() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178 34.2 SHA1() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179 34.3 SHA256() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179 34.4 SHA512() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179 34.5 SHA384() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180 34.6 SHA224() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180 34.7 Encrypt() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180 34.8 Decrypt() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181 34.9 Encryption and Decryption Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181 34.10 File Hash . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181 34.11 Randbytes() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181 34.12 Download() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182 34.13 SendEmail() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182 35 Object Oriented Programming (OOP) 183 35.1 Classes and Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183 35.2 Access Objects Using Braces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185 35.3 Composition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186 35.4 Setter and Getter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187 35.5 Private Attributes and Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187 35.6 Operator Overloading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188 35.7 Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189 35.8 Dynamic Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190 35.9 Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190 35.10 Printing Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191 35.11 Find() and List of Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191 35.12 Sort() and list of objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192 35.13 Using Self.Attribute and Self.Method() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194 35.14 Using This.Attribute and This.Method() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195 36 Functional Programming 196 36.1 Pure Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196 36.2 First-class Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 36.3 Higher-order Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 36.4 Anonymous and Nested Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198 36.5 Equality of functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199 37 Reflection and Meta-programming 201 37.1 locals() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201 37.2 globals() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201 viii