SlideShare a Scribd company logo
Ring Documentation, Release 1.5
• const char *getpairingFinishedEvent(void)
95.175 QBluetoothServer Class
C++ Reference : http://doc.qt.io/qt-5/QBluetoothServer.html
Parameters : QBluetoothServiceInfo::Protocol,QObject *
Parent Class : QObject
• void close(void)
• QBluetoothServer::Error error(void)
• bool hasPendingConnections(void)
• bool isListening(void)
• bool listen(QBluetoothAddress address, quint16 port)
• QBluetoothServiceInfo listen_2(QBluetoothUuid uuid, QString serviceName))
• int maxPendingConnections(void)
• QBluetoothSocket * nextPendingConnection(void)
• QBluetooth::SecurityFlags securityFlags(void)
• QBluetoothAddress serverAddress(void)
• quint16 serverPort(void)
• QBluetoothServiceInfo::Protocol serverType(void)
• void setMaxPendingConnections(int numConnections)
• void setSecurityFlags(QBluetooth::SecurityFlags security)
• void seterrorEvent(const char *)
• void setnewConnectionEvent(const char *)
• const char *geterrorEvent(void)
• const char *getnewConnectionEvent(void)
95.176 QBluetoothServiceDiscoveryAgent Class
C++ Reference : http://doc.qt.io/qt-5/QBluetoothServiceDiscoveryAgent.html
Parameters : QObject *
Parent Class : QObject
• QList<QBluetoothServiceInfo> discoveredServices(void)
• QBluetoothServiceDiscoveryAgent::Error error(void)
• QString errorString(void)
• bool isActive(void)
• QBluetoothAddress remoteAddress(void)
• bool setRemoteAddress(QBluetoothAddress address)
95.175. QBluetoothServer Class 1686
Ring Documentation, Release 1.5
• void setUuidFilter(QList<QBluetoothUuid> uuids)
• void setUuidFilter_2(QBluetoothUuid uuid)
• QList<QBluetoothUuid> uuidFilter(void)
• void clear(void)
• void start(QBluetoothServiceDiscoveryAgent::DiscoveryMode mode)
• void stop(void)
• void setcanceledEvent(const char *)
• void seterrorEvent(const char *)
• void setfinishedEvent(const char *)
• void setserviceDiscoveredEvent(const char *)
• const char *getcanceledEvent(void)
• const char *geterrorEvent(void)
• const char *getfinishedEvent(void)
• const char *getserviceDiscoveredEvent(void)
95.177 QBluetoothServiceInfo Class
C++ Reference : http://doc.qt.io/qt-5/QBluetoothServiceInfo.html
Parameters : void
• QVariant attribute(quint16 attributeId)
• QList<quint16> attributes(void)
• bool contains(quint16 attributeId)
• QBluetoothDeviceInfo device(void)
• bool isComplete(void)
• bool isRegistered(void)
• bool isValid(void)
• QBluetoothServiceInfo::Sequence protocolDescriptor(QBluetoothUuid::ProtocolUuid protocol)
• int protocolServiceMultiplexer(void)
• bool registerService(QBluetoothAddress localAdapter))
• void removeAttribute(quint16 attributeId)
• int serverChannel(void)
• quint8 serviceAvailability(void)
• QList<QBluetoothUuid> serviceClassUuids(void)
• QString serviceDescription(void)
• QString serviceName(void)
• QString serviceProvider(void)
95.177. QBluetoothServiceInfo Class 1687
Ring Documentation, Release 1.5
• QBluetoothUuid serviceUuid(void)
• void setAttribute(quint16 attributeId, QVariant value)
• void setAttribute_2(quint16 attributeId, QBluetoothUuid value)
• void setAttribute_3(quint16 attributeId, QBluetoothServiceInfo::Sequence value)
• void setDevice(QBluetoothDeviceInfo device)
• void setServiceAvailability(quint8 availability)
• void setServiceDescription(QString description)
• void setServiceName(QString name)
• void setServiceProvider(QString provider)
• void setServiceUuid(QBluetoothUuid uuid)
• bool unregisterService(void)
95.178 QBluetoothSocket Class
C++ Reference : http://doc.qt.io/qt-5/QBluetoothSocket.html
Parameters : QBluetoothServiceInfo::Protocol,QObject *
Parent Class : QIODevice
• void abort(void)
• void connectToService(QBluetoothServiceInfo service, QIODevice::OpenMode openMode)
• void connectToService_2(QBluetoothAddress address, QBluetoothUuid uuid, QIODevice::OpenMode open-
Mode)
• void connectToService_3(QBluetoothAddress address, quint16 port, QIODevice::OpenMode openMode)
• void disconnectFromService(void)
• QBluetoothSocket::SocketError error(void)
• QString errorString(void)
• QBluetoothAddress localAddress(void)
• QString localName(void)
• quint16 localPort(void)
• QBluetoothAddress peerAddress(void)
• QString peerName(void)
• quint16 peerPort(void)
• bool setSocketDescriptor(int socketDescriptor, QBluetoothServiceInfo::Protocol socketType, QBluetooth-
Socket::SocketState socketState, QIODevice::OpenMode openMode)
• int socketDescriptor(void)
• QBluetoothServiceInfo::Protocol socketType(void)
• QBluetoothSocket::SocketState state(void)
• void setconnectedEvent(const char *)
95.178. QBluetoothSocket Class 1688
Ring Documentation, Release 1.5
• void setdisconnectedEvent(const char *)
• void seterrorEvent(const char *)
• void setstateChangedEvent(const char *)
• const char *getconnectedEvent(void)
• const char *getdisconnectedEvent(void)
• const char *geterrorEvent(void)
• const char *getstateChangedEvent(void)
95.179 QBluetoothTransferManager Class
C++ Reference : http://doc.qt.io/qt-5/QBluetoothTransferManager.html
Parameters : QObject *
Parent Class : QObject
• QBluetoothTransferReply * put(QBluetoothTransferRequest request, QIODevice *data)
• void setfinishedEvent(const char *)
• const char *getfinishedEvent(void)
95.180 QBluetoothTransferReply Class
C++ Reference : http://doc.qt.io/qt-5/QBluetoothTransferReply.html
Parameters : QObject *
Parent Class : QObject
• QBluetoothTransferManager * manager(void)
• QBluetoothTransferRequest request(void)
• void abort(void)
• void seterrorEvent(const char *)
• void setfinishedEvent(const char *)
• void settransferProgressEvent(const char *)
• const char *geterrorEvent(void)
• const char *getfinishedEvent(void)
• const char *gettransferProgressEvent(void)
95.181 QBluetoothTransferRequest Class
C++ Reference : http://doc.qt.io/qt-5/QBluetoothTransferRequest.html
Parameters : QBluetoothAddress
• QBluetoothAddress address(void)
95.179. QBluetoothTransferManager Class 1689
Ring Documentation, Release 1.5
• QVariant attribute(QBluetoothTransferRequest::Attribute code, QVariant defaultValue))
• void setAttribute(QBluetoothTransferRequest::Attribute code, QVariant value)
95.182 QBluetoothUuid Class
C++ Reference : http://doc.qt.io/qt-5/QBluetoothUuid.html
Parameters : void
Parent Class : QUuid
• int minimumSize(void)
• quint16 toUInt16(bool *ok)
• quint32 toUInt32(bool *ok)
• quint128 toUInt128(void)
• QString characteristicToString(QBluetoothUuid::CharacteristicType uuid)
• QString descriptorToString(QBluetoothUuid::DescriptorType uuid)
• QString protocolToString(QBluetoothUuid::ProtocolUuid uuid)
• QString serviceClassToString(QBluetoothUuid::ServiceClassUuid uuid)
95.182. QBluetoothUuid Class 1690
CHAPTER
NINETYSIX
FREQUENTLY ASKED QUESTIONS (FAQ)
96.1 Why do we need Yet Another Programming Language (YAPL)?
The language comes with better support for Natural Language Programming and Declarative Programming. The inno-
vation comes in supporting these paradigms with new practical techniques on the top of Object-Oriented Programming
and Functional Programming. Ring provide the programmers with the tools required to build a Natural Language like
Supernova or Declarative Language like REBOL and QML without the need to know anything about (Compilers and
Parsing). You get the language constructs ready for use to create domain-specific languages in a fraction of time.
Check the Supernova programming language, In this language you can type (I want window and the window title is
hello world.) and it will create a GUI window with “Hello, World!” as the window title. When I created Supernova
language in 2010. I discovered that using the Natural Code can be (Like English without limits and we can get the
human language power in programming) but to implement that You need a new language that are
1. General Purpose
2. Practical
3. Can create Natural Languages very quickly.
So we can get a System that can increase ease of use and productivity to the maximum level.
Ring is the best language to do that. So I created Ring to achieve this goal.
Supernova was just a test for the idea. To get a near view about what are the Advantages and Disadvantages. After
testing the new ideas you provide something practical. So we have Ring after Supernova. A story that maybe similar
to having Python after ABC. Python avoid ABC problems but bring ABC advantages. Also Ring learn from Ruby and
ROR story. The language power could appears in Frameworks better than direct usage as a general purpose language.
Also Ring comes with a clear goal/motivation (Creating a new version of the PWCT Software) something learned
from designing the C language to create the Unix Operating System. You have a goal that direct you in each design
decision.
You will understand the value of our decisions once you start trying to solve the problem that we will use Ring to
solve. Could you enable any one in the world without knowledge about computer programming concepts to create very
powerful software? In science the answer is (Visual Programming) and (Natural Programming). In practical we still
away from switching to these paradigms without introducing other problems. Ring is designed to solve this problem.
It’s designed to provide Natural Programming in a practical way. And to create a powerful Visual Programming tool.
Ring is designed to be a new world of programming after 10 years of research in Visual Programming and Natural
Languages.
The Ring Programming Language (Compiler+VM) is developed 100% using Visual Programming without writing a
single line of code. I used my tool (Programming Without Coding Technology) to design everything and get the C
code generated for me. Advantages ?
1. More Faster
2. No Syntax Errors
1691
Ring Documentation, Release 1.5
3. Easy to understand and manage the code because the Abstraction level is more higher
4. No Critical Disadvantages because you can control everything as writing your code.
From my experience in using Visual Programming for 10 years and Natural Programming for 5 years I designed Ring
to move the knowledge to mainstream programmers by providing a practical language that support these ideas.
I agree that each programmer/developer has the freedom to form his opinions about any software including program-
ming languages. Ring is not an exception but you may miss the idea behind the language. It’s innovative and may
help you to think different about how to solve your problems. Maybe this is not clear to many programmers because
It’s practical language and includes many features known to programmers and when a programmer look at a language
he/she may think that nothing new because it’s familiar. I created Ring to solve problems in a different way. Where I
will start programming just by describing the software using new natural interfaces that I will implement later when
I move from the design stage to the implementation stage. (I don’t determine the time to switch between stages, You
are free to use Agile methods). Since Ring is a new language you have 3 options.
1. Just don’t care.
2. Think in the future of the language and help us if you understand the idea and want to contribute.
3. Wait and come back again in the future to use it.
Summary:
• Ring is designed based on a need to develop a new version of the PWCT software.
Once we finish PWCT 2.0 we will have good and large software developed using Ring.
• We will push Declarative and Natural paradigms many steps forward. Also in next versions
we have a plan to present a new paradigm for Network Programming and Concurrency. We tested this new paradigm
through simple prototypes during the last years and we will integrate it with Ring in Future releases.
96.2 Why Ring is weakly typed?
Because it’s more Natural, and Faster and this is important for the language goals. What comes first is what you want.
When you type “Print : ” + 5 , The String comes first then 5 will be converted to a String. while when you type 5 +
“10” The number comes first so “10” will be converted to 10. This help a lot to quickly convert between numbers and
strings using the same operator. If you want to prevent conversion (Write code that prevent conversion) In these cases
you will notice that what you are writing is less code (And can be removed).
Weakly Typed = Automatic Conversion and Automatic is Good Thing and is better than Manual if you know how to
use it correctly.
96.3 What are the advantages to using Ring over Lisp or Smalltalk?
Smalltalk and Lisp are GREAT languages. I like many of the concepts behind them but I’m sure that selecting the
right programming language is based on the problem and comes after the problem definition. I have a problem that I
want to solve and these GREAT languages are not ideal for this problem so I designed Ring.
When you design a new language, You can learn from the past but you must look forward and live in the Future. What
you know about Natural Programming maybe based on the Old Knowledge about the power of these paradigms in the
practical world and I agree with you but I see another techniques that can be applied to get this to work in practical.
What you miss about Natural Language is that they are Context Sensitive and this means we can use it and think
different about how we can express our ideas.
example : I want window contains 3 buttons.
96.2. Why Ring is weakly typed? 1692
Ring Documentation, Release 1.5
In one sentence I created 4 objects (The window and the three buttons) and added the buttons to the window. The idea
of Natural Programming is to get many things done like that.
96.4 Why Ring is largely focussed on UI creation?
Yes UI creation is one of the important things in the language features because it’s designed to create a visual pro-
gramming tool, But the language is a multi-paradigm language where we can select the programming paradigm based
on the problem.
96.5 Is Ring some sort of improvement over PHP?
Ring is not designed to replace PHP, Lua and/or Smalltalk. And Ring support for Declarative Programming and
Natural Language Programming is very innovative and much better than staying with Procedural, Object-Oriented and
Functional Languages. Ring see the future in programming without code (Using Natural Languages) and is designed
to support that.
96.6 What are the advantages to using Ring over native C or C++?
Ring provides a better way to mix between different programming paradigms in solving problems.
The different programming paradigms play well together in the same language.
1. It’s easy to switch from one programming paradigm to another one because the language constructs use similar
syntax for similar concepts.
2. The paradigms are provided to interact and used together in different layers in the software.
for example you can create a game engine using object-oriented programming but write the game code using declara-
tive programming or natural programming and behind the scene your declarative or natural code will use the object-
oriented classes.
3. Ring is very productive and natural programming language than C/C++ languages.
4. Ring is a dynamic language. We can generate and execute code during the runtime. We have dynamic typing
and weakly typed language for flexibility.
5. The Garbage collector is generational (escape analysis) and also use reference counting. it’s very fast and still
provide control to the programmer who can delete memory at any time.
6. Ring Compiler and Virtual Machine is just 15,000 lines of ANSI C code that can be compiled and used in any
platform.
7. You can use C/C++ libraries and Ring comes with code generator to create wrappers from C functions or C++
classes. so when you need more performance or when you need to use more libraries you can easily do that.
96.7 What is the difference between Ring and Python? And is Ring
Open Source?
Yes the language is Free Open Source (MIT license)
In general I like Python and Ruby but I was looking for a language more suitable for creating the next version of the
Programming Without Coding Technology (PWCT) software so I started the Ring design.
96.4. Why Ring is largely focussed on UI creation? 1693
Ring Documentation, Release 1.5
Some simple changes that matters for my goal are
1. Not case sensitive
2. The list index start from 1
3. You can call functions before definition
4. Don’t use Python syntax like (indentation, using self, :, pass & _)
5. Weakly typed (convert automatically between types based on context)
6. The programs follow simple and constant structure (Statements then functions then packages and classes)
7. Using the ‘=’ operator for assignment and for testing values
Critical changes are
1. Small Language : The Ring compiler + Virtual Machine = 15K lines of C code , the other 500K lines are related
to libraries and are optional when we go for using the language in C/C++ programs.
2. The Garbage collector : Uses Escape Analysis/Reference counting and give the programmer the ability to
determine when to delete memory using the assignment operator
3. Compact Syntax : Ring is not line sensitive, you don’t need to write ; or press ENTER to separate between
statements
4. Using { } to access the object then using the object attributes and methods directly
5. Natural Programming : It’s very easy to create natural interfaces using Ring based on OOP
6. Declarative Programming using Nested Structure
The Ring programming language is designed based on my experience from using many other languages like C, C++,
C#, Lua, PHP, Python, Ruby, Harbour, Basic and Supernova And the language comes with innovative features added
to achieve the language goal
• Applications programming language.
• Productivity and developing high quality solutions that can scale.
• Small and fast language that can be embedded in C/C++ projects.
• Simple language that can be used in education and introducing Compiler/VM concepts.
• General-Purpose language that can be used for creating domain-specific libraries, frameworks and tools.
• Practical language designed for creating the next version of the Programming Without Coding Technology
software.
96.8 What are the advantages to using Ring over Perl, PHP, Python
or Ruby?
1. Ring is New and Innovative. The language will let you think different about programming.
2. Ring is Smaller. (Lessons learned from the Lua language)
3. Ring is Simple. (Lessons learned from the BASIC and Clipper/Harbour languages)
4. Ring is more Natural. (Lessons learned from the Supernova language)
5. Ring is more Declarative. (Lessons learned from REBOL and QML languages)
6. Ring Implementation is Transparent, Visual and comes with Rich Features.
96.8. What are the advantages to using Ring over Perl, PHP, Python or Ruby? 1694
Ring Documentation, Release 1.5
96.9 What are the advantages to using Ring over Tcl or Lua?
1. Clean Code (More Natural)
2. More Features (A lot of useful programming paradigms)
96.10 What are the advantages to using Ring over C# or Java?
1. Compact Code (Clean and Natural), More Productivity and Flexibility.
2. Better support for Declarative Programming and Natural Programming
96.11 The documentation says functional programming is sup-
ported, but then this happens?
The question was about this code
f = func {
a = 42
return func { return a }
}
innerF = call f()
call innerF()
Output:
Using uninitialized variable : a In function _ring_anonymous_func_16601()
The Answer:
• It’s Anonymous Functions, i.e. Not Closures.
• Many developers asked about supporting Closures and during language development we may add new features
that doesn’t go against the language goals or sprite.
• You can use classes and objects when you want to merge between the state and functions to provide a clear
solution.
• You can use Lists and put the anonymous function inside the List then return the list that contains the state and
the function. Pass the list to the function when you use it.
• You can use eval() and substr() to add the variable value directly to the anonymous function before return.
• We protect you from other scopes when you define the function. In Ring we provided the Three Scopes Rule
where at each point you have only at maximum three scopes (Global, Object Scope and Local Scope).
• We don’t get everything from everywhere to be like others! We don’t need to do that. If we will think like that
then we will create a very complex language or we will save our time and use other languages.
• When you think about learning or studying a new language concentrate about (What is new?) and (What is
better in this language?) to know when to use it. Don’t compare a new language just released little months ago
with languages started many years ago and expect to find everything that you used to have.
• Each programming language miss features in other languages. The idea is not the Features. it’s the sprite and
ability behind all of the features together.
96.9. What are the advantages to using Ring over Tcl or Lua? 1695
Ring Documentation, Release 1.5
96.12 Why the ability to define your own languages Instead of just
handing over the syntax so you can parse it using whatever
code you like?
It’s innovation - You create natural statements without the need to learn about parsing. You just use Classes which is
intelligent decision (where later we can mix between classes to support more statements based on the context - We can
change and translate the defined statements and many more!). Also the statements are added in Ring World where you
can use any Ring statement.
96.13 Why you can specify the number of loops you want to break
out of?
The language supports programming in the small and programming in the large. The selection of what features to
use is based on what are you going to do. Any programmer can write poorly code in any language if he/she wants to
do that. The idea is what must be done in the language design to prevent errors without causing other problems like
killing flexibility.
Read some source code in the Linux Kernel and Ruby Implementation for example, You will find good usage for
GOTO as a practical example that General Rules are not for All Use Cases and great programmers know when to
break the rules. I’m not saying go and use GOTO or saying Ring add things like that. But the ability to break more
than one loop and/or the ability to break the loop from sub functions is practical for small programs.
Anyway these are some of the small new things added by the language (Not the big idea).
96.14 Why Ring uses ‘See’, ‘Give’, ‘But’ and ‘Ok’ Keywords?
See and Give are selected not to be “opposite actions” but to reflect what I want to do as a programmer.
When I want to see something on the screen I use ‘See’.
When I want to give some input to the program I use ‘Give’.
My selection of “but” and “ok” is based on selecting keywords that can be written quickly.
Also using “but” is easy to remember than elseif/elif/elsif where each language select a different keyword.
In Ring 1.1 and later versions All of this is just an option.
You can use ‘Put’ and ‘Get’ instead of ‘See’ and ‘Give’
You can use ‘elseif’ and ‘end’ insetad of ‘But’ and ‘Ok’
It’s your choice. In Ring we have syntax flexibility where we provide more than one style.
Also you can change the language keywords and operators.
Also you can define new natural languages too.
96.15 What is the philosophy behind data types in Ring?
The Ring programming language is designed to be SMALL. The language provides the basic constructs that you need
to do anything! One of the goals is to keep the basic constructs simple and small as possible.
96.12. Why the ability to define your own languages Instead of just handing over the syntax so you
can parse it using whatever code you like?
1696
Ring Documentation, Release 1.5
Using Lists in Ring you can
• Create Arrays (one data type)
• Create Lists (Mix of data types)
• Create Tree (Nested arrays)
• Use String Index (Looks like Dictionary/Hash Table)
The same principle is applied to Numbers
• You can use the number for int value
• You can use the number for double value
• You can use the number for Boolean value (True/False)
The sample principle is applied for Strings
• You can use the string for storing one character
• You can use the string for storing text (one or many lines)
• You can use the string for storing binary data
• You can use the string for storing date
• You can use the string for storing time
• You can use the string for storing NULL values (empty strings)
And we have Object Oriented Support + Operator Overloading where the programmer can define new data types and
use them as default types defined by the language
So We have
• A small and simple language that someone can pick in little days
• A fast language that provide primitive types (String ? Number ? List ? Object)
• A flexible language that can be extended using OOP to add new types according to the application domain
96.16 What about the Boolean values in Ring?
You can use true for 1 and false for 0
when you test the result of Boolean expressions in your code.
Just when you print the value using the see command you will see 1 for (true) and 0 for (false)
Why ?
Because Ring contains only 4 types of variables
1. Number
2. String
3. List
4. Object
The first type (Number) is used to represent int, double and Boolean values.
The second type (String) is used to represent char, array of characters, date and time.
96.16. What about the Boolean values in Ring? 1697
Ring Documentation, Release 1.5
The third type (List) is used to represent Arrays of one type, Arrays of more than one type, Hash (Dictionary), Tree,
etc.
The object can be an object created from a Ring class (Any Class) or just a C Pointer that we get from calling a C/C++
function/method.
Why ?
The Ring is designed to give the programmer/developer the most simple constructs that can be used to do everything.
The programmer/developer can customize the language by creating new classes (and use operator overloading) to get
more types that he care about according to the problem domain.
Why ?
Because simple is better, and easy to learn and remember! And this provide flexibility to convert between high level
types that can be represented using the same basic type
96.17 What is the goal of including the “Main” function in Ring?
The main function is very important, you need it when you want to write statements that uses local variables instead
of the Global scope.
Example:
x = 10
myfunc()
See "X value = " + X # here I expect that x will be (10)
# but I will get another value (6) because myfunc() uses x !
Func myfunc
for x = 1 to 5
See x + nl
next
Output:
1
2
3
4
5
X value = 6
Now using the Main function
Func Main
x = 10
myfunc()
See "X value = " + X
Func myfunc
for x = 1 to 5
See x + nl
next
Output
1
2
3
96.17. What is the goal of including the “Main” function in Ring? 1698
Ring Documentation, Release 1.5
4
5
X value = 10
96.18 Why the list index start from 1 in Ring?
It’s about how we count in the real world, when we have three apples in our hand
we say 1 2 3
We don’t start from 0
The question must be why the other languages start from 0 ?
The answer is, because this is related to the machine and how we deal with values and memory address.
Example
we have array called myarray[5]
In memory : myarray will have an address
The first item will be stored in that address
The second item will come after that address and so on
Now when we need to point to the first item we need the address of myarray
So we type myarray[0] because myarray + 0 result will still point to the first item
for the second item myarray[1] because myarray + 1 result will point to the second item and so on
In Low Level languages or languages near to the machine it’s good to be like this
But for high level language designed for applications it’s better to be natural
Example
mylist = [1,2,3,4,5]
for x = 1 to len(mylist)
see x + nl
next
In the previous example we start from 1 to the length of the array if the index starts from 0 we will write
for x = 0 to len(mylist)-1
or remember the for loop in other languages
for(x=0 ; x<nMax ; x++ )
You will use the < operator !
96.19 Why Ring is not case-sensitive?
1. To be more human-friendly
2. Like Ada, SQL, Pascal, Delphi, Visual Basic, Visual FoxPro, etc.
3. To help in supporting Natural Language Programming.
96.18. Why the list index start from 1 in Ring? 1699
Ring Documentation, Release 1.5
4. To be able to select your favorite style when writing the language keywords
see "lower case!"
SEE "UPPER case!"
See "First Letter is UPPER case!"
5. To avoid getting error message when writing quick tests then type “variable” instead of “Variable”.
6. To avoid getting error message when you type “Dosomething()” instead of “doSomething()”
7. In Ring, No conflict between Variables, Method Names & Classes Names
We can write person as variable name and Person as class name.
person = new Person
class Person
name address phone
96.20 Why the Assignment operator uses Deep Copy?
“Because it’s a poor tradeoff to add complexity for dubious performance gains, a good approach to deep vs. shallow
copies is to prefer deep copies until proven otherwise.”
, Steve McConnell, Code Complete
1. It’s more natural, When you use the assignment operator, You expect a deep copy.
2. If you don’t need a deep copy, Just don’t use it!
3. The Ring language is designed to reduce references usage as much as possible.
4. The Ring language is designed to make using references simple and possible in special cases where this make
sense.
5. We have references when this is natural, like passing lists and objects to functions, creating objects (Like
GUI Objects) from a C/C++ library, returning an object stored inside a list.
6. It is a feature, We can use it to create pure functions. The Value() function in the stdlib uses this feature to
pass lists & objects by value when we need this.
7. When we need references, It’s recommended to create a class that manage sharing lists and objects.
8. It’s more safe at the application level to avoid many logical errors.
9. In Ring, we start without thinking about the little details and concentrate on the application, You don’t
have to write the type (Dynamic Typing), You don’t have to write explicit conversions between numbers
and strings (Weakly Typed) and you don’t have to select between using values or references, You don’t
have to write the scope (Lexical Scoping).
10. In Ring, we have smart garbage collector (Simple & Fast), We can delete the memory directly at any
time using the Assignment operator too. Reducing references usage or using them through managers
helps a lot to achieve this goal. by doing this we have full control.
11. If you want to create references and avoid creating a manager, You can use Object2Pointer() and Pointer2Object() functio
But It’s not the Ring way “Sprite” to do things.
96.20. Why the Assignment operator uses Deep Copy? 1700
Ring Documentation, Release 1.5
96.21 Is there constructor methods in Ring?
When you create new object for example
new point
1 - Ring will allocate dynamic memory space to be used for the new object attributes that Ring doesn’t know anything
about them.
2 - Ring will change the current local scope and the current object scope to use the object state created in step (1)
3 - Ring will move the execution to the class Region (After the class name and before any methods)
4 - Any Instructions/Code in the class region will be executed as any Ring code
5 - Control is moved from the class region to the location of (new point) once we reach the end of the class region or
we uses a Return command.
So All attributes that added to the object are dynamic attributes, this mean that you can control what attributes will be
added through the runtime.
Example:
$3D = False
see new point
$3D = True
see new point
class point
x y
if not $3D return ok
z
Output:
x: NULL
y: NULL
x: NULL
y: NULL
z: NULL
You have an option to call init() method directly when you create a new object
This method can do anything with the object attributes as it will be called after creating the object and executing the
class region code.
p1 = new point3d(100,200,300)
see p1
class point3d
x y z
func init p1,p2,p3
x=p1 y=p2 z=p3
96.22 What happens when we create a new object?
1- When you create an object, the class region code will be executed and you will have the object attributes based on
the code in that region
96.21. Is there constructor methods in Ring? 1701
Ring Documentation, Release 1.5
2- Ring don’t care about the object methods until you start calling a method
3- When you call a method, Ring will check the object class and the class parent (if you are using inheritance) and
will collect the methods for you to be used now or later from any object that belong to the same class.
4- Since methods are dynamic and each object get the method from the class, you can after creating objects, add new
methods and use it with the object or any object created or will be created from the same class.
Example:
o1 = new point {x=10 y=20 z=30}
o2 = new point {x=100 y=200 z =300}
addmethod(o1,"print", func { see x + nl + y + nl + z + nl } )
o1.print()
o2.print()
class point x y z
Output:
10
20
30
100
200
300
96.23 Can we use the attributes by accessing the Getter and Setter
methods?
Yes we can, The setter/getter methods are called automatically when you start using the attributes from outside the
class Also you can call the methods instead of using the attributes. It’s your choice.
Example:
o1 = new Developer
o1.name = "Mahmoud" see o1.name + nl
o1 { name = "Gal" see name }
o1 { name = "Bert" see name }
o1.setname("Marino")
see o1.getname()
Class Developer
name language = "Ring Programming Language"
func setname value
see "Message from SetName() Function!" + nl
name = value + " - " + language
func getname
see "Message from GetName() Function!" + nl + nl
return "Mr. " + name + nl
Output
96.23. Can we use the attributes by accessing the Getter and Setter methods? 1702
Ring Documentation, Release 1.5
Message from SetName() Function!
Message from GetName() Function!
Mr. Mahmoud - Ring Programming Language
Message from SetName() Function!
Message from GetName() Function!
Mr. Gal - Ring Programming Language
Message from SetName() Function!
Message from GetName() Function!
Mr. Bert - Ring Programming Language
Message from SetName() Function!
Message from GetName() Function!
Mr. Marino - Ring Programming Language
96.24 Why should a search of global names be made while defining
the class attributes?
The question is why we don’t avoid conflicts with global variable names when we define the class attributes ?
At first remember that using the optional $ mark in the global variables names solve the problem. Also using the Main
function and avoiding global variables may help.
The Answer:
Ring is a dynamic language
We can in the run-time determine the class attributes (Add/Remove)
We can execute (any code) while defining the class attributes
Example (1)
oPerson = new Person
Class Person
See "Welcome to the Ring language"
Example (2)
Customize attributes based on global variable value
$debug = true
oPerson = new Person
see oPerson
Class Person
if $debug date=date() time=time() ok
In the previous example when we have the $debug flag set to true, we will add the Date and Time attributes to the
object state.
Example (3)
Store the object index based on global variable
96.24. Why should a search of global names be made while defining the class attributes? 1703
Ring Documentation, Release 1.5
$ObjectsCount = 0
oPerson = new Person
see oPerson
oPerson2 = new Person
see oPerson2
Class Person
$ObjectsCount++
nIndex = $ObjectsCount
Output:
nindex: 1.000000
nindex: 2.000000
Common Example:
• Connect to the database then get table columns (Using global Variable/Object).
• Create class attributes based on the column names.
• Later when you modify the database - you may don’t need to modify your code.
It’s flexibility but remember that power comes with great responsibility.
96.25 Why Ring doesn’t avoid the conflict between Global Variables
and Class Attributes Names?
In this use case we have
1 - Global Variable defined without a special mark like $
2 - Class contains Attributes defined using a special syntax (where we type the attribute name directly after the class)
3 - The Attributes are defined in the class region that allows writing code and using global variables
If I will accepted your proposal about changing how Ring find variables in the class region I must break one of the
previous three features which will lead to more problems that are more important than this problem.
I don’t like changing the feature number (1) because I would like to keep Ring code more clean and let the programmer
decide when to use $ or not.
I don’t like changing the feature number (2) because I like this feature and I don’t like forcing the programmer to type
self.attribute
I don’t like changing the feature number (3) because it’s very important in many applications to access global variables
in the class region.
So what was my decision ?
I decided to leave this case for the programmer who will decide what to do to avoid this special case
1 - The programmer can avoid using global variables (Better) and can use the Main function (Optional)
2 - The programmer can use $ before the variable name or any mark like global_ or g_
3 - The programmer can use self.attribute after the class name to define the attributes
In general, for small programs you can use global variables and functions. For large programs, use classes and objects
and small number of global variables or avoid them at all.
96.25. Why Ring doesn’t avoid the conflict between Global Variables and Class Attributes Names?1704
Ring Documentation, Release 1.5
96.26 Where can I write a program and execute it?
Run the Ring Notepad where you can write/execute programs.
If you want to run programs using the command line
Add Ring/bin folder to the path then
96.27 How to get the file size using ftell() and fseek() functions?
The next function can be used to get the file size without reading the file!
func getFileSize fp
C_FILESTART = 0
C_FILEEND = 2
fseek(fp,0,C_FILEEND)
nFileSize = ftell(fp)
fseek(fp,0,C_FILESTART)
return nFileSize
Note: The previous function take the fp (file pointer) as parameter, We can get the fp from opening the file using
fopen() function.
fp = fopen("filename","r")
see "File Size : " + getFileSize(fp) + nl
Another solution (Read the file)
see len(read("filename"))
96.28 How to get the current source file path?
We can use the next function to get the current source file path then we can add the path variable to the file name
cPath = CurrentPath()
func currentpath
cFileName = filename()
for x = len(cFileName) to 1 step -1
if cFileName[x] = "/"
return left(cFileName,x-1)
ok
next
return cFileName
96.29 What about predefined parameters or optional parameters in
functions?
if you want to use predefined parameters or optional parameters Just accept a list that works like hash/dictionary
Example
96.26. Where can I write a program and execute it? 1705
Ring Documentation, Release 1.5
sum([ :a = 1, :b = 2])
sum([ :a = 1 ])
sum([ :b = 2 ])
func sum pList
if plist[:a] = NULL pList[:a] = 4 ok
if plist[:b] = NULL pList[:b] = 5 ok
see pList[:a] + pList[:b] + nl
Output
3
6
6
96.30 How to print keys or values only in List/Dictionary?
If you want to print keys only or values only just select the index of the item (one or two).
Example
C_COUNTRY = 1
C_CITY = 2
mylist = [
:KSA = "Riyadh" ,
:Egypt = "Cairo"
]
for x in mylist
see x[C_COUNTRY] + nl
next
for x in mylist
see x[C_CITY] + nl
next
Output
ksa
egypt
Riyadh
Cairo
96.31 Why I get a strange result when printing nl with lists?
In the next code
list = 1:5 # list = [1,2,3,4,5]
see list + nl
New Line will be added to the list then the list will be printed, the default print of the lists will print a newline at the
end, You added new newline and You have now 2 newlines to be printed.
See <Expr>
The see command just print the final result of the expression, the expression will be evaluated as it
96.30. How to print keys or values only in List/Dictionary? 1706
Ring Documentation, Release 1.5
nl = char(13) + char(10) # just a variable that you can change to anything !
The + is an operator
string + string ---> new string
string + number ---> new string
number + number ---> new number
number + string ---> new number
list + item —> nothing new will be created but the item will be added to the same list
Exception
number + nl ?> New String
This exception is added to easily print numbers then new line.
No need for this with printing lists because after printing the last item we already get a new line.
96.32 Could you explain the output of the StrCmp() function?
At first remember that you can check strings using ‘=’ operator directly.
see strcmp("hello","hello") + nl +
strcmp("abc","bcd") + nl +
strcmp("bcd","abc") + nl
if the two strings are the same then it returns 0
abc and bcd aren’t the same. in the second line it returns -1 and in the third line it returns 1
In the second line we compare between “abc” and “bcd”
Not equal because the first letter in “abc” = “a” and the first letter in “bcd” = “b”
So we have “a” != “b” and “a” < “b”
So we get output = -1
In the third line we have “bcd” and “abc”
the first letter in “bcd” is “b” and the first letter in “abc” is “a”
So we have “b” != “a” and “b” > “a”
So we get output = 1
Note: ASCII(“a”) = 97 and ASCII(“b”) = 98 So “a” < “b” because 97 < 98
96.33 How to use many source code files in the project?
Example:
I have the next folder
C:LRing
Contains the next files
96.32. Could you explain the output of the StrCmp() function? 1707
Ring Documentation, Release 1.5
C:LRingt1.ring
C:LRingmylib.ring
C:LRinglibsmylib2.ring
The file t1.ring contains the next code
load "mylib.ring"
load "libsmylib2.ring"
myfunc()
test()
The file mylib.ring contains the next code
func myfunc
see "message from myfunc"+nl
The file libsmylib2.ring contains the next code
func test
see "message from test" + nl
from the folder C:LRing
If Ring is not added to the path you can add it or use the next command
set path=%path%;c:ringbin;
Where c:ring is the Ring folder
Now run
Ring t1.ring
Output
message from myfunc
message from test
96.34 Why this example use the GetChar() twice?
The GetChar() function accept one character from the keyboard buffer
In this example
While True
See "
Main Menu
(1) Say Hello
(2) Exit
"
Option = GetChar()
GetChar() GetChar() # End of line
# the previous two lines can be replaced with the next line
# Give Option
if Option = 1
see "Enter your name : " give cName
see "Hello " + cName
else
96.34. Why this example use the GetChar() twice? 1708
Ring Documentation, Release 1.5
bye
ok
End
We uses GetChar() Three times
The first time we get the user option
Option = GetChar()
But in the second and the third times (We accept the new line characters from the buffer)
GetChar() GetChar() # End of line
Example : when the user select the option number 1 then press ENTER
We have Three Characters
• The first character is : Number 1
• The second character is : CHAR(13)
• The third character is : CHAR(10)
Because Windows uses CHAR(13) and CHAR(10) for each new line ( i.e. CR+LF )
96.35 How to use NULL and ISNULL() function?
when we try to use uninitialized variable in the Ring programming language, we get a clear runtime error message
Example
See x
Output
Line 1 Error (R24) : Using uninitialized variable : x
in file testsseeuninit.ring
The same happens when you try to access uninitialized attributes
Example
o1 = new point
see o1
see o1.x
class point x y z
Output
x: NULL
y: NULL
z: NULL
Line 3 Error (R24) : Using uninitialized variable : x
in file testsseeuninit2.ring
if you want to check for the error, just use Try/Catch/End
96.35. How to use NULL and ISNULL() function? 1709
Ring Documentation, Release 1.5
Try
see x
Catch
See "Sorry, We can't use x!" + nl
Done
Output
Sorry, We can't use x!
Now we will talk about NULL and ISNULL()
Since we get error message when we deal with uninitialized variables
We can check these errors using Try/Catch/Done, So we uses NULL and ISNULL() for dealing with Strings.
NULL is a variable contains an empty string
ISNULL() is a function that returns true (1) if the input is an empty string or just a string contains “NULL”
This because we need to test these values (empty strings) and strings contains “NULL” that sometimes come from
external resource like DBMS.
Example
See IsNull(5) + nl + # print 0
IsNull("hello") + nl + # print 0
IsNull([1,3,5]) + nl + # print 0
IsNull("") + nl + # print 1
IsNull("NULL") # print 1
96.36 How to print lists that contains objects?
In this example we will see how we can print a list contains objects.
aList = [[1,2,3] , new point(1,2,3), new point(1,2,3)]
see "print the list" + nl
see alist
see "print the item (object)" + nl
see alist[2]
class point x y z
func init p1,p2,p3 x=p1 y=p2 z=p3
Output
print the list
1
2
3
x: 1.000000
y: 2.000000
z: 3.000000
x: 1.000000
y: 2.000000
z: 3.000000
print the item (object)
x: 1.000000
y: 2.000000
z: 3.000000
96.36. How to print lists that contains objects? 1710
Ring Documentation, Release 1.5
96.37 How to insert an item to the first position in the list?
To insert an item we can use the insert(aList,nIndex,Value) function.
aList = 1:5
insert(aList,0,0)
See aList # print numbers from 0 to 5
96.38 How to print new lines and other characters?
To print new line we can use the nl variable.
See "Hello" + nl
or we can use multi-line literal as in the next example
See "Hello
"
if we want to print other characters we can use the char(nASCII) function
See char(109) + nl + # print m
char(77) # print M
96.39 Why we don’t use () after the qApp class name?
When we use RingQt to create GUI application, we uses () after the class name when we create new objects for
example.
new qWidget() { setWindowTitle("Hello World") resize(400,400) show() }
but before doing that we create an object from the qApp class and we don’t use () after that
Load "guilib.ring"
app = new qApp
{
win=new qWidget()
{
setwindowtitle(:test)
show()
}
exec()
}
Using () after the class name means calling the init() method in the class and passing parameters to this method.
If we used () while no init() method in the class we get the expected error message.
The class qApp don’t have this method while the other classes have it because they need it to create an object using
a function that return a pointer to that object and this pointer will be stored in an attribute called pObject, for more
information see ring_qt.ring file which contains the classes.
96.37. How to insert an item to the first position in the list? 1711
Ring Documentation, Release 1.5
96.40 Why the window title bar is going outside the screen?
When we write the next code
Load "guilib.ring"
app = new qApp
{
win=new qWidget()
{
setwindowtitle(:test)
setGeometry(0,0,200,200)
show()
}
exec()
}
I would expect that the window will run at the point (0,0) with (200,200) size but the actual result is that the window
title bar is going outside the screen.
This is related to the behavior of Qt framework.
The next code will avoid the problem
load "guilib.ring"
new qApp {
new qWidget() {
move(0,0)
resize(200,200)
show()
}
exec()
}
96.41 How to create an array of buttons in GUI applications?
Check the next example:
Load "guilib.ring"
App1 = new qApp {
win1 = new qWidget() {
move(0,0)
resize(500,500)
new qPushButton(win1)
{
settext("OK")
setclickevent("click()")
}
btn1 = new qPushButton(win1)
{
setgeometry(100,100,100,30)
settext("Button1")
}
btn2 = new qPushButton(win1)
{
96.40. Why the window title bar is going outside the screen? 1712
Ring Documentation, Release 1.5
setgeometry(200,100,100,30)
settext("Button2")
}
button = [btn1, btn2]
show()
}
exec()
}
func click
button[1] { settext ("Button3") }
button[2] { settext ("Button4") }
96.42 How to Close a window then displaying another one?
This example demonstrates how to close a window and show another one
Load "guilib.ring"
app=new qApp
{
frmBefore=new Qwidget()
{
setWindowTitle("before!")
resize(300,320)
move(200,200)
button=new qPushButton(frmBefore)
{
setText("Close")
setClickEvent("frmBefore.close() frmMain.show()")
}
show()
}
frmMain=new Qwidget()
{
setWindowTitle("After!")
resize(300,320)
move(200,200)
}
exec()
}
96.43 How to create a Modal Window?
This example demonstrates how to create a modal window
96.42. How to Close a window then displaying another one? 1713
Ring Documentation, Release 1.5
load "guilib.ring"
app=new qApp
{
frmStart=new Qwidget()
{
setWindowTitle("The First Window")
resize(300,320)
move(200,200)
button=new qPushButton(frmStart)
{
setText("Show Modal Window")
resize(200,30)
setClickEvent("frmModal.show()")
}
new qPushButton(frmStart)
{
setText("Close Window")
move(0,50)
resize(200,30)
setClickEvent("frmStart.Close()")
}
show()
}
frmModal =new Qwidget()
{
setWindowTitle("Modal Window")
resize(300,320)
move(200,200)
setparent(frmStart)
setwindowmodality(true)
setwindowflags(Qt_Dialog)
}
exec()
}
Related Documents
• http://doc.qt.io/qt-5/qtwidgets-widgets-windowflags-example.html
• http://doc.qt.io/qt-5/qt.html#WindowType-enum
• http://doc.qt.io/qt-5/qwindow.html#setParent
• http://doc.qt.io/qt-5/qt.html#WindowModality-enum
96.44 How can I disable maximize button and resize window?
Use the method setWindowFlags()
Load "guilib.ring"
app1 = new qapp {
win1 = new qwidget() {
96.44. How can I disable maximize button and resize window? 1714
Ring Documentation, Release 1.5
setwindowtitle("First")
setgeometry(100,100,500,500)
new qpushbutton(win1) {
setgeometry(100,100,100,30)
settext("close")
setclickevent("app1.quit()")
}
new qpushbutton(win1) {
setgeometry(250,100,100,30)
settext("Second")
setclickevent("second()")
}
showmaximized()
}
exec()
}
func second
win2 = new qwidget() {
setwindowtitle("Second")
setgeometry(100,100,500,500)
setwindowflags(Qt_dialog)
show()
}
96.45 How to use SQLite using ODBC?
In Ring 1.1 and later versions we have native support for SQLite, so you don’t need to use it through ODBC.
Also we can access SQLite through RingQt.
The answer to your question
pODBC = odbc_init()
odbc_connect(pODBC,"DRIVER=SQLite3 ODBC Driver;Database=mydb.db;LongNames=0;"+
"Timeout=1000;NoTXN=0;SyncPragma=NORMAL;StepAPI=0;")
odbc_execute(pODBC,"create table 'tel' ('ID','NAME','PHONE');")
odbc_execute(pODBC,"insert into 'tel' values ('1','Mahmoud','123456');")
odbc_execute(pODBC,"insert into 'tel' values ('2','Ahmed','123456');")
odbc_execute(pODBC,"insert into 'tel' values ('3','Ibrahim','123456');")
odbc_execute(pODBC,"select * from tel") + nl
nMax = odbc_colcount(pODBC)
See "Columns Count : " + nMax + nl
while odbc_fetch(pODBC)
See nl
for x = 1 to nMax
see odbc_getdata(pODBC,x)
if x != nMax see " - " ok
next
end
odbc_disconnect(pODBC)
odbc_close(pODBC)
Output:
96.45. How to use SQLite using ODBC? 1715
Ring Documentation, Release 1.5
Columns Count : 3
1 - Mahmoud - 123456
2 - Ahmed - 123456
3 - Ibrahim - 123456
The program will create the file : mydb.db
Note : when I print the odbc drivers I see the long list that includes
SQLite3 ODBC Driver - UsageCount=1
SQLite ODBC Driver - UsageCount=1
SQLite ODBC (UTF-8) Driver - UsageCount=1
And I’m using “SQLite3 ODBC Driver”.
96.46 Can I connect to dbase/harbour database?
You can connect to any database using ODBC
To connect to xbase files (*.DBF)
See "Using DBF Files using ODBC" + nl
pODBC = odbc_init()
See "Connect to database" + nl
odbc_connect(pODBC,"Driver={Microsoft dBase Driver (*.dbf)};"+
"datasource=dBase Files;DriverID=277")
See "Select data" + nl
odbc_execute(pODBC,"select * from tel.dbf")
nMax = odbc_colcount(pODBC)
See "Columns Count : " + nMax + nl
while odbc_fetch(pODBC)
See "Row data:" + nl
for x = 1 to nMax
see odbc_getdata(pODBC,x) + " - "
next
end
See "Close database..." + nl
odbc_disconnect(pODBC)
odbc_close(pODBC)
Output
Using DBF Files using ODBC
Connect to database
Select data
Columns Count : 3
Row data:
Ahmad - Egypt - 234567 - Row data:
Fady - Egypt - 345678 - Row data:
Shady - Egypt - 456789 - Row data:
Mahmoud - Egypt - 123456 - Close database...
Also you can connect to a Visual FoxPro database (requires installing Visual FoxPro driver)
See "ODBC test 6" + nl
pODBC = odbc_init()
See "Connect to database" + nl
96.46. Can I connect to dbase/harbour database? 1716
Ring Documentation, Release 1.5
odbc_connect(pODBC,"Driver={Microsoft Visual FoxPro Driver};"+
"SourceType=DBC;SourceDB=C:PWCT19ssbuildPWCTDATACH1Datamydata.dbc;")
See "Select data" + nl
see odbc_execute(pODBC,"select * from t38") + nl
nMax = odbc_colcount(pODBC)
See "Columns Count : " + nMax + nl
while odbc_fetch(pODBC)
See "Row data:" + nl
for x = 1 to nMax
see odbc_getdata(pODBC,x) + " - "
next
end
See "Close database..." + nl
odbc_disconnect(pODBC)
odbc_close(pODBC)
96.47 Why setClickEvent() doesn’t see the object methods directly?
setClickEvent(cCode) take a string contains code. The code will be executed when the event happens.
Ring support Many Programming Paradigms like Procedural, OOP, Functional and others.
But when you support many paradigms at the language level you can’t know which paradigm will be used so you have
two options
1. Provide General Solutions that works with many programming paradigms.
2. Provide Many Specific solutions where each one match a specific paradigm.
setClickEvent() and others belong to (General Solutions that works with many programming paradigms).
You just pass a string of code that will be executed without any care about classes and objects.
This code could be anything like calling a function, calling a method and setting variable value.
Some other languages force you to use OOP and call methods for events. Also some other languages uses anonymous
functions that may get parameters like the current object.
Now we have the general solution (not restricted with any paradigm), In the future we may add specific solutions that
match specific paradigms (OOP, Functional, Declarative and Natural).
96.48 Why I get Calling Function without definition Error?
Each program follow the next order
1 - Loading Files 2 - Global Variables and Statements 3 - Functions 4 - Packages, Classes and Methods
So what does that mean ?
1. **** No Functions comes After Classes ****
2. **** No command is required to end functions/methods/classes/packages ****
Look at this example
See "Hello"
test()
func test
96.47. Why setClickEvent() doesn’t see the object methods directly? 1717
Ring Documentation, Release 1.5
see "message from the test function!" + nl
class test
In the previous example we have a function called test() so we can call it directly using test()
In the next example, test() will become a method
See"Hello"
test() # runtime error message
class test
func test # Test() now is a method (not a function)
see "message from the test method!" + nl
The errors comes when you define a method then try calling it directly as a function.
The previous program must be
See"Hello"
new test { test() } # now will call the method
class test
func test # Test() now is a method (not a function)
see "message from the test method!" + nl
96.49 Can Ring work on Windows XP?
Ring can work on Windows XP and load extensions without problems.
Just be sure that the extension can work on Windows XP and your compiler version support that (modern compilers
requires some flags to support XP)
Check this topic https://blogs.msdn.microsoft.com/vcblog/2012/10/08/windows-xp-targeting-with-c-in-visual-studio-
2012/
For example, We added
/link /SUBSYSTEM:CONSOLE,"5.01"
To the batch file to support Windows XP
See : https://github.com/ring-lang/ring/blob/master/src/buildvccomplete.bat
96.50 How to extend RingQt and add more classes?
You have many options
In general you can extend Ring using C or C++ code
Ring from Ring code you can call C Functions or use C++ Classes & Methods
This chapter in the documentation explains this part in the language http://ring-
lang.sourceforge.net/doc/extension.html
For example the next code in .c file can be compiled to a DLL file using the Ring library (.lib)
#include "ring.h"
RING_FUNC(ring_ringlib_dlfunc)
{
96.49. Can Ring work on Windows XP? 1718
Ring Documentation, Release 1.5
printf("Message from dlfunc");
}
RING_API void ringlib_init(RingState *pRingState)
{
ring_vm_funcregister("dlfunc",ring_ringlib_dlfunc);
}
Then from Ring you can load the DLL file using LoadLib() function then call the C function that called dlfunc() as
any Ring function.
See "Dynamic DLL" + NL
LoadLib("ringlib.dll")
dlfunc()
Output
Dynamic DLL
Message from dlfunc
When you read the documentation you will know about how to get parameters like (strings, numbers, lists and objects)
And how to return a value (any type) from you function.
From experience, when we support a C library or C++ Library
We discovered that a lot of functions share a lot of code
To save our time, and to quickly generate wrappers for C/C++ Libraries to be used in Ring
We have this code generator
https://github.com/ring-lang/ring/blob/master/extensions/codegen/parsec.ring
The code generator is just a Ring program < 1200 lines of Ring code
The generator take as input a configuration file contains the C/C++ library information
like Functions Prototype, Classes and Methods, Constants, Enum, Structures and members , etc.
Then the generator will generate
*.C File for C libraries (to be able to use the library functions)
*.CPP File for C++ libraries (to be able to use C++ classes and methods)
*.Ring File (to be able to use C++ classes as Ring classes)
*.RH file (Constants)
To understand how the generator work check this extension for the Allegro game programming library
https://github.com/ring-lang/ring/tree/master/extensions/ringallegro
At first we have the configuration file
https://github.com/ring-lang/ring/blob/master/extensions/ringallegro/allegro.cf
To write this file, i just used the Allegro documentation + the Ring code generator rules
Then after executing the generator using this batch file
https://github.com/ring-lang/ring/blob/master/extensions/ringallegro/gencode.bat
or using this script
https://github.com/ring-lang/ring/blob/master/extensions/ringallegro/gencode.sh
96.50. How to extend RingQt and add more classes? 1719
Ring Documentation, Release 1.5
I get the generated source code file
https://github.com/ring-lang/ring/blob/master/extensions/ringallegro/ring_allegro.c
The generated source code file (ring_allegro.c) is around 12,000 Lines of code (12 KLOC)
While the configuration file is less than 1 KLOC
To build the library (create the DLL files)
https://github.com/ring-lang/ring/blob/master/extensions/ringallegro/buildvc.bat
Also you can check this extension for the LibSDL Library
https://github.com/ring-lang/ring/tree/master/extensions/ringsdl
After this know you should know about
1 - Writing the configuration file
2 - Using the Code Generator
3 - Building your library/extension
4 - Using your library/extension from Ring code
Let us move now to you question about Qt
We have RingQt which is just an extension to ring (ringqt.dll)
You don’t need to modify Ring.
1. You just need to modify RingQt
2. Or extend Ring with another extension based on Qt (but the same Qt version)
For the first option see the RingQt extension
https://github.com/ring-lang/ring/tree/master/extensions/ringqt
Configuration file
https://github.com/ring-lang/ring/blob/master/extensions/ringqt/qt.cf
To generate the source code
https://github.com/ring-lang/ring/blob/master/extensions/ringqt/gencode.bat
https://github.com/ring-lang/ring/blob/master/extensions/ringqt/gencode.sh
https://github.com/ring-lang/ring/blob/master/extensions/ringqt/gencodeandroid.bat
To build the DLL/so/Dylib files
https://github.com/ring-lang/ring/blob/master/extensions/ringqt/buildmingw32.bat
https://github.com/ring-lang/ring/blob/master/extensions/ringqt/buildgcc.sh
https://github.com/ring-lang/ring/blob/master/extensions/ringqt/buildclang.sh
Study RingQt
Learn about the options that you have
1. wrapping a Qt class directly
2. Creating a new class then wrapping your new class
96.50. How to extend RingQt and add more classes? 1720
Ring Documentation, Release 1.5
For the second option (in the previous two points or in the two points before that)
You will create new classes in C++ code
Then you merge these classes to RingQt or provide special DLL for them (your decision)
If your work is general (will help others) just put it to RingQt.
if your work is special (to specific application) just put it in another extension.
96.51 How to add Combobox and other elements to the cells of a
QTableWidget?
Check the next code
Load "guilib.ring"
New qApp
{
win1 = new qMainWindow() {
setGeometry(100,100,1100,370)
setwindowtitle("Using QTableWidget")
Table1 = new qTableWidget(win1) {
setrowcount(10) setcolumncount(10)
setGeometry(0,0,800,400)
setselectionbehavior(QAbstractItemView_SelectRows)
for x = 1 to 10
for y = 1 to 10
item1 = new qtablewidgetitem("R"+X+"C"+Y)
setitem(x-1,y-1, item1)
next
next
cmb = new QComboBox(Table1) {
alist = ["one","two","three","four","five"]
for x in aList additem(x,0) next
}
setCellWidget(5, 5, cmb)
}
setcentralwidget(table1)
show()
}
exec()
}
96.52 How to perform some manipulations on selected cells in
QTableWidget?
Check the next sample
Load "guilib.ring"
New qApp {
96.51. How to add Combobox and other elements to the cells of a QTableWidget? 1721
Ring Documentation, Release 1.5
win1 = new qMainWindow() {
setGeometry(100,100,800,600)
setwindowtitle("Using QTableWidget")
Table1 = new qTableWidget(win1) {
setrowcount(10) setcolumncount(10)
setGeometry(10,10,400,400)
for x = 1 to 10
for y = 1 to 10
item1 = new qtablewidgetitem("10")
setitem(x-1,y-1,item1)
next
next
}
btn1 = new qPushButton(win1) {
setText("Increase")
setGeometry(510,10,100,30)
setClickEvent("pClick()")
}
show()
}
exec()
}
func pClick
for nRow = 0 to Table1.rowcount() - 1
for nCol = 0 to Table1.columncount() - 1
Table1.item(nRow,nCol) {
if isSelected()
setText( "" + ( 10 + text()) )
ok
}
next
next
96.52. How to perform some manipulations on selected cells in QTableWidget? 1722
CHAPTER
NINETYSEVEN
LANGUAGE REFERENCE
In this chapter we will learn about
• Language keywords
• Language Functions
• Compiler Errors
• Runtime Errors
• Language Grammar
• Virtual Machine (VM) Instructions
97.1 Language Keywords
Keywords Count : 49
• again
• and
• but
• bye
• call
• case
• catch
• changeringkeyword
• changeringoperator
• class
• def
• do
• done
• else
• elseif
• end
• exit
1723
Ring Documentation, Release 1.5
• for
• from
• func
• get
• give
• if
• import
• in
• load
• loadsyntax
• loop
• new
• next
• not
• off
• ok
• on
• or
• other
• package
• private
• put
• return
• see
• step
• switch
• to
• try
• while
• endfunc
• endclass
• endpackage
97.1. Language Keywords 1724
Ring Documentation, Release 1.5
97.2 Language Functions
Functions Count : 197
len() add() del() sysget() clock() lower()
upper() input() ascii() char() date() time()
filename() getchar() system() random() timelist() adddays()
diffdays() version() clockspersecond() prevfilename() swap() shutdown()
isstring() isnumber() islist() type() isnull() isobject()
hex() dec() number() string() str2hex() hex2str()
str2list() list2str() left() right() trim() copy()
substr() lines() strcmp() eval() raise() assert()
isalnum() isalpha() iscntrl() isdigit() isgraph() islower()
isprint() ispunct() isspace() isupper() isxdigit() locals()
globals() functions() cfunctions() islocal() isglobal() isfunction()
iscfunction() packages() ispackage() classes() isclass() packageclasses()
ispackageclass() classname() objectid() attributes() methods() isattribute()
ismethod() isprivateattribute() isprivatemethod()
addattribute() addmethod() getattribute()
setattribute() mergemethods() packagename() ringvm_fileslist()
ringvm_calllist() ringvm_memorylist()
ringvm_functionslist() ringvm_classeslist() ringvm_packageslist()
ringvm_cfunctionslist() ringvm_settrace() ringvm_tracedata()
ringvm_traceevent() ringvm_tracefunc() ringvm_scopescount()
ringvm_evalinscope() ringvm_passerror() ringvm_hideerrormsg()
ringvm_callfunc() list() find() min() max() insert()
sort() reverse() binarysearch() sin() cos() tan()
asin() acos() atan() atan2() sinh() cosh()
tanh() exp() log() log10() ceil() floor()
fabs() pow() sqrt() unsigned() decimals() murmur3hash()
fopen() fclose() fflush() freopen() tempfile() tempname()
fseek() ftell() rewind() fgetpos() fsetpos() clearerr()
feof() ferror() perror() rename() remove() fgetc()
fgets() fputc() fputs() ungetc() fread() fwrite()
dir() read() write() fexists() int2bytes() float2bytes()
double2bytes() bytes2int() bytes2float()
bytes2double() ismsdos() iswindows()
iswindows64() isunix() ismacosx() islinux() isfreebsd() isandroid()
windowsnl() currentdir() exefilename() chdir() exefolder() loadlib()
closelib() callgc() varptr() intvalue() object2pointer() pointer2object()
nullpointer() space() ptrcmp() ring_state_init()
ring_state_runcode() ring_state_delete()
ring_state_runfile() ring_state_findvar() ring_state_newvar()
ring_state_runobjectfile()
97.3 Compiler Errors
• Error (C1) : Error in parameters list, expected identifier
• Error (C2) : Error in class name
• Error (C3) : Unclosed control strucutre, ‘ok’ is missing
• Error (C4) : Unclosed control strucutre, ‘end’ is missing
• Error (C5) : Unclosed control strucutre, next is missing
• Error (C6) : Error in function name
97.2. Language Functions 1725
Ring Documentation, Release 1.5
• Error (C7) : Error in list items
• Error (C8) : Parentheses ‘)’ is missing
• Error (C9) : Brackets ‘]’ is missing
• Error (C10) : Error in parent class name
• Error (C11) : Error in expression operator
• Error (C12) : No class definition
• Error (C13) : Error in variable name
• Error (C14) : Try/Catch miss the Catch keyword!
• Error (C15) : Try/Catch miss the Done keyword!
• Error (C16) : Error in Switch statement expression!
• Error (C17) : Switch statement without OFF
• Error (C18) : Missing closing brace for the block opened!
• Error (C19) : Numeric Overflow!
• Error (C20) : Error in package name
• Error (C21) : Unclosed control strucutre, ‘again’ is missing
• Error (C22) : Function redefinition, function is already defined!
• Error (C23) : Using ‘(‘ after number!
• Error (C24) : The parent class name is identical to the subclass name
• Error (C25) : Trying to access the self reference after the object name”
• Error (C26) : Class redefinition, class is already defined!
97.4 Runtime Errors
• Error (R1) : Cann’t divide by zero !
• Error (R2) : Array Access (Index out of range) !
• Error (R3) : Calling Function without definition !
• Error (R4) : Stack Overflow !
• Error (R5) : Can’t access the list item, Object is not list !
• Error (R6) : Variable is required
• Error (R7) : Can’t assign to a string letter more than one character
• Error (R8) : Variable is not a string
• Error (R9) : Using exit command outside loops
• Error (R10) : Using exit command with number outside the range
• Error (R11) : error in class name, class not found!
• Error (R12) : error in property name, property not found!
• Error (R13) : Object is required
97.4. Runtime Errors 1726
Ring Documentation, Release 1.5
• Error (R14) : Calling Method without definition !
• Error (R15) : error in parent class name, class not found!
• Error (R16) : Using braces to access unknown object !
• Error (R17) : error, using ‘Super’ without parent class!
• Error (R18) : Numeric Overflow!
• Error (R19) : Calling function with less number of parameters!
• Error (R20) : Calling function with extra number of parameters!
• Error (R21) : Using operator with values of incorrect type
• Error (R22) : Using loop command outside loops
• Error (R23) : Using loop command with number outside the range
• Error (R24) : Using uninitialized variable
• Error (R25) : Error in package name, Package not found!
• Error (R26) : Calling private method from outside the class
• Error (R27) : Using private attribute from outside the class
• Error (R28) : Using bad data type as step value
• Error (R29) : Using bad data type in for loop
• Error (R30) : parent class name is identical to child class name
• Error (R31) : Trying to destory the object using the self reference
• Error (R32) : The CALL command expect a variable contains string!
• Error (R33) : Bad decimals number (correct range >= 0 and <=14) !
• Error (R34) : Variable is required for the assignment operation
• Error (R35) : Can’t create/open the file!
• Error (R36) : The column number is not correct! It’s greater than the number of columns in the list
• Error (R37) : Sorry, The command is not supported in this context
• Error (R38) : Runtime Error in loading the dynamic library!
97.5 Language Grammar
Program —> {statement}
Statement —> ‘package’ <Identifier> { ‘.’ <Identifier> } [’{‘ {statement} ‘}’] [’end’|’endpackage’]
Statement —> ‘class’ <Identifier> [ ‘from’|’:’|’<’ <Identifier> ] [’{‘ {statement} ‘}’][’end’|’endclass’]
Statement —> ‘func’|’def’ <Identifier> [ParaList] [’{‘ {statement} ‘}’][’end’|’endfunc’]
Statement —> ‘import’ <Identifier> { ‘.’ <Identifier> }
Statement —> ‘private’
Statement —> ‘load’ <Literal>
Statement —> ‘loadsyntax’ <Literal>
97.5. Language Grammar 1727
Ring Documentation, Release 1.5
Statement —> ‘changeringkeyword’ <OldKeyword> <NewKeyword>
Statement —> ‘changeringoperator’ <OldOperator> <NewOperator>
Statement —> ‘see’|’put’ <Expr>
Statement —> ‘give’|’get’ <Identifier>
Statement —> ‘if’ <Expr> [’{‘] {statement} [ {‘but’|’elseif’ <Expr> {Statement} } ] [’else’ {Statement} ]
‘ok’|’end’|’}’
Statement —> ‘Switch’ <Expr> [’{‘] { ‘on’|’case’ <Expr> {statement} } [’other’ {Statement} ] ‘off’|’end’|’}’
Statement —> ‘for’ <Identifier> ‘=’ <Expr> ‘to’ <Expr> [ ‘step’ <Expr> ] [’{‘] {Statement} ‘next’|’end’|’}’
Statement —> ‘for’ <Identifier> ‘in’ <Expr> [ ‘step’ <Expr> ] [’{‘] {statement} ‘next’|’end’|’}’
Statement —> ‘while’ <Expr> [’{‘] {statement} ‘end’|’}’
Statement —> ‘do’ {statement} ‘again’ <Expr>
Statement —> ‘try’ {statement} [’{‘] ‘catch’ {statement} ‘done’|’end’|’}’
Statement —> ‘return’ <Expr>
Statement —> ‘bye’
Statement —> ‘exit’
Statement —> ‘loop’
Statement —> <Expr>
Statement —> epslion
ParaList —> epslion
ParaList —> [’(‘] <Identifier> [{ ‘,’ <Identifier> }] [’)’]
Expr —> <LogicNot> [{ ‘and’|’or’ <LogicNot> }]
LogicNot –> [’not’] <EqualOrNot>
EqualOrNot –> [ ‘=’|’!=’ ] <Compare>
Compare —> <BitOrXor> [ { ‘<’ | ‘>’ | ‘<=’ | ‘>=’ <BitOrXor> } ]
BitOrXor —> <BitAnd> [ { ‘|’ | ‘^’ <BitAnd> } ]
BitAnd —> <BitShift> [ { ‘&’ <BitShift> } ]
BitShift —> <Arithmetic> [ { ‘<<’ | ‘>>’ <Arithmetic> } ]
Arithmetic —> <Term> [ { ‘+’ | ‘-‘ <Term> } ]
Term —> <Range> [ { ‘*’ | ‘/’ | ‘%’ <Range> } ]
Range —> <Factor> [ ‘:’ <Factor> ]
Factor —> <Identifier> [ {Mixer} ] [ ‘=’ <Expr> ]
Factor —> <Number>
Factor —> <Literal>
Factor —> ‘:’ <Identifier>
Factor —> ‘-‘ <Expr>
Factor —> ‘(‘ <Expr> ‘)’
97.5. Language Grammar 1728
Ring Documentation, Release 1.5
Factor —> <List>
Factor —> ‘new’ <Identifier>
Factor —> <AnonymousFunction>
Factor —> ‘call’ <identifier> { ‘.’ <Identifier> } ‘(‘ <Parameters> ‘)’
List —> ‘[’ [ <Expr> { ‘,’ <Expr> } ] ‘]’
Mixer —> { ‘.’ <Identifier> }
Mixer —> ‘[’ <Expr> ‘]’
Mixer —> ‘(‘ [ <Expr> [ { ‘,’ <Expr> }] ] ‘)’
Mixer —> ‘{‘ {Statement} ‘}’
AnonymousFunction —> ‘func’|’def’| [<ParaList>] ‘{‘ {Statement} ‘}’
97.6 Virtual Machine (VM) Instructions
Definitions :-
• VM : Virtual Machine
• Stack : VM Stack
• IR : Instruction Register
• PC : Program Counter
• VP : Variable Pointer
• Stack[nSize] : Last Item in the Stack (Last In - First Out)
• VV : Variable Value (We have a Pointer to a variable, And we access this variable value)
(Stack and Variables)
97.6. Virtual Machine (VM) Instructions 1729
Ring Documentation, Release 1.5
Operation Description
• ICO_PUSHC
Add string from the IR to the stack
• ICO_PUSHN
Add number from the IR to the stack
• ICO_PUSHV
Replace VP in the stack[nSize] with the variable value
• ICO_LOADADDRESS
Read variable name from the IR, push VP to the stack
• ICO_ASSIGNMENT
Stack[nSize-1] VV = Stack[nSize] VV , POP
Stack[nSize]
• ICO_INC
Increment Number in Stack[nSize] by 1
• ICO_LOADAPUSHV
The same as ICO_LOADADDRESS then ICO_PUSHV
• ICO_NEWLINE
Store new line number (debug info)
• ICO_FREESTACK
Remove all items from the stack , nSize = 0
• ICO_FILENAME
Store the source code file name (debug info)
• ICO_FREELOADASCOPE
Free the Scope List of the current Expression
(Jump)
Operation Description
• ICO_JUMP
Set PC to new value from the IR
• ICO_JUMPZERO
If Stack[nSize] is a number = 0 then Set PC to new value
from the IR
• ICO_JUMPFOR
End of for loop
• ICO_JUMPONE
If Stack[nSize] is a number = 1 then Set PC to new value
from the IR
• ICO_JUMPZERO2
As ICO_JUMPZERO but add 1 to the stack (required
for many ‘AND’ conditions)
• ICO_JUMPONE2
As ICO_JUMPONE but add 1 to the stack (required for
many ‘OR’ conditions)
(Compare)
97.6. Virtual Machine (VM) Instructions 1730
Ring Documentation, Release 1.5
Operation Description
• ICO_LESSEQUAL
If stack[nSize-1] <= stack[nSize] , POP stack[nSize], set
Stack[nSize-1] = 1 else set Stack[nSize-1] = 0
• ICO_EQUAL
If stack[nSize-1] = stack[nSize] , POP stack[nSize], set
Stack[nSize-1] = 1 else set Stack[nSize-1] = 0
• ICO_LESS
If stack[nSize-1] < stack[nSize] , POP stack[nSize], set
Stack[nSize-1] = 1 else set Stack[nSize-1] = 0
• ICO_GREATER
If stack[nSize-1] > stack[nSize] , POP stack[nSize], set
Stack[nSize-1] = 1 else set Stack[nSize-1] = 0
• ICO_GREATEREQUAL
If stack[nSize-1] >= stack[nSize] , POP stack[nSize], set
Stack[nSize-1] = 1 else set Stack[nSize-1] = 0
• ICO_NOTEQUAL
If stack[nSize-1] != stack[nSize] , POP stack[nSize], set
Stack[nSize-1] = 1 else set Stack[nSize-1] = 0
(Math)
Operation Description
• ICO_SUM
Stack[nSize-1] = Stack[nSize-1] + Stack[nSize] , POP
stack[nSize]
• ICO_SUB
Stack[nSize-1] = Stack[nSize-1] - Stack[nSize] , POP
stack[nSize]
• ICO_MUL
Stack[nSize-1] = Stack[nSize-1] * Stack[nSize] , POP
stack[nSize]
• ICO_DIV
Stack[nSize-1] = Stack[nSize-1] / Stack[nSize] , POP
stack[nSize]
• ICO_MOD
Stack[nSize-1] = Stack[nSize-1] % Stack[nSize] , POP
stack[nSize]
• ICO_NEG
Stack[nSize] = - Stack[nSize-1]
• ICO_PLUSPLUS
Stack[nSize] = Stack[nSize] + 1
• ICO_MINUSMINUS
Stack[nSize] = Stack[nSize] - 1
(Logic)
Operation Description
• ICO_AND
Stack[nSize-1] = Stack[nSize-1] && Stack[nSize] ,
POP stack[nSize]
• ICO_OR
Stack[nSize-1] = Stack[nSize-1] || Stack[nSize] , POP
stack[nSize]
• ICO_NOT
Stack[nSize] = ! Stack[nSize]
(Lists)
97.6. Virtual Machine (VM) Instructions 1731
Ring Documentation, Release 1.5
Operation Description
• ICO_LISTSTART
Start New List in Temp. Memory
• ICO_LISTITEM
Add List Item
• ICO_LISTEND
End List
• ICO_LOADINDEXADDRESS
Stack[nSize-1] = Stack[nSize-1] VV [ Stack[nSize] ] ,
POP stack[nSize]
(Functions)
Operation Description
• ICO_LOADFUNC
Find function
• ICO_CALL
Call function
• ICO_RETURN
Return from function
• ICO_RETNULL
Return NULl from function
• ICO_RETFROMEVAL
Return after eval()
• ICO_RETITEMREF
Return the list item reference - not the value
• ICO_NEWFUNC
Start new function
• ICO_BLOCKFLAG
Flag to determine where to jump later (after
ICO_RETURN)
• ICO_FUNCEXE
Start executing function
• ICO_ENDFUNCEXE
End function execution
• ICO_ANONYMOUS
Anonymous function
(User Interface)
Operation Description
• ICO_PRINT
Print value to the standard output
• ICO_GIVE
Get input from the keyboard
(End Program/Loop)
97.6. Virtual Machine (VM) Instructions 1732
Ring Documentation, Release 1.5
Operation Description
• ICO_BYE
End execution of VM
• ICO_EXITMARK
Place to exit to from a loop
• ICO_POPEXITMARK
Remove exit mark
• ICO_EXIT
Break from one loop or more
• ICO_LOOP
Continue to next loop
(For Better Performance)
Operation Description
• ICO_PUSHP
Push pointer to the stack
• ICO_INCP
Increment variable value using pointer
• ICO_PUSHPV
Push value of variable using variable pointer
• ICO_INCJUMP
Increment then jump
• ICO_INCPJUMP
Increment using pointer then jump
• ICO_JUMPVARLENUM
Jump if variable value is <= numeric value
• ICO_JUMPVARPLENUM
Jump if variable value (using pointer) <= numeric value
• ICO_LOADFUNCP
Push function pointer
• ICO_PUSHPLOCAL
Push pointer to local variable
• ICO_INCLPJUMP
Increment value using pointer to local variable then
jump
• ICO_JUMPVARLPLENUM
Jump if the variable value (using pointer) <= numeric
value
• ICO_INCPJUMPSTEP1
Increment value using variable pointer then jump (for
loop step = 1)
• ICO_JUMPVARPLENUMSTEP1
Increment value using variable pointer then jump (for
loop step = 1)
(Try-Catch-Done)
97.6. Virtual Machine (VM) Instructions 1733
Ring Documentation, Release 1.5
Operation Description
• ICO_TRY
Start try region
• ICO_DONE
End try region
(Duplicate and Range)
Operation Description
• ICO_DUPLICATE
Duplicate stack value
• ICO_RANGE
Create list from value to value
(OOP)
Operation Description
• ICO_NEWOBJ
Create new object, get class name from the IR, push ob-
ject pointer to the stack.
• ICO_SETSCOPE
Called after creating new object, set the active scope to
be the object scope.
• ICO_LOADSUBADDRESS
Get object attribute, push the pointer to the stack.
• ICO_LOADMETHOD
Find object method
• ICO_AFTERCALLMETHOD
Used after calling a method - normal case
• ICO_AFTERCALLMETHOD2
Used after calling a method - second case
• ICO_NEWCLASS
Start new class region
• ICO_BRACESTART
Open brace
• ICO_BRACEEND
End brace
• ICO_IMPORT
Import package
• ICO_PRIVATE
start private attributes region
• ICO_SETPROPERTY
set attribute value - check for setter.
• ICO_CALLCLASSINIT
call call init() method.
(Other)
97.6. Virtual Machine (VM) Instructions 1734
Ring Documentation, Release 1.5
Operation Description
• ICO_SETREFERENCE
Copy by reference
• ICO_KILLREFERENCE
Remove reference
• ICO_ASSIGNMENTPOINTER
Determine the left side variable
• ICO_BEFOREEQUAL
Determine operators like += , -= , ... etc
(Bitwise Operators)
Operation Description
• ICO_BITAND
Stack[nSize-1] = Stack[nSize-1] & Stack[nSize] , POP
stack[nSize]
• ICO_BITOR
Stack[nSize-1] = Stack[nSize-1] | Stack[nSize] , POP
stack[nSize]
• ICO_BITXOR
Stack[nSize-1] = Stack[nSize-1] ^ Stack[nSize] , POP
stack[nSize]
• ICO_BITNOT
Stack[nSize] = ! Stack[nSize]
• ICO_BITSHL
Stack[nSize-1] = Stack[nSize-1] << Stack[nSize] , POP
stack[nSize]
• ICO_BITSHR
Stack[nSize-1] = Stack[nSize-1] >> Stack[nSize] , POP
stack[nSize]
(For Step)
Operation Description
• ICO_STEPNUMBER
Determine step number in for loop
• ICO_POPSTEP
POP step number from steps stack
• ICO_LOADAFIRST
Load the first address of variable name
97.6. Virtual Machine (VM) Instructions 1735
CHAPTER
NINETYEIGHT
RESOURCES
In this section you will find resources about the language
98.1 Ring Language Website
For news about the language check the website
http://ring-lang.net
http://ring-lang.sf.net
98.2 Ring Group
For questions use the Ring Group (English)
https://groups.google.com/forum/#!forum/ring-lang
98.3 Contact the Authors
Name : Eng. Mahmoud Samir Fayed
Country : Egypt
Email : msfclipper@yahoo.com
Facebook : https://facebook.com/mahmoudfayed1986
LinkedIn : https://sa.linkedin.com/in/mahmoudfayed1986
Name : Dr. Atif M. Alamri
Country : Saudi Arabia
Email : atif@ksu.edu.sa
LinkedIn : https://sa.linkedin.com/in/dr-atif-alamri-8b341747
Ring Team : http://ring-lang.sourceforge.net/team.html
1736
INDEX
Access List Items by String Index
Lists, 174
Access Objects Using Braces
Object Oriented Programming, 251
Access String Letters
Strings, 176
Accessing the class attributes from braces inside class
methods
Scope Rules, 655
Add Items
Lists, 168
addattribute()
Reflection and Meta-programming, 278
AddDays()
Date and Time, 184
Adding code to the generated code
Code Generator, 740
Adding Hyperlink to QLabel
Desktop and Mobile Development, 559
addmethod()
Reflection and Meta-programming, 278
Analog Clock
Applications developed in little hours, 5
Animate Class
Game Engine for 2D Games, 432
Animate Events
Game Engine for 2D Games, 443
Animation
Game Engine for 2D Games, 437
Animation and Functions
Game Engine for 2D Games, 438
Anonymous and Nested Functions
Functional Programming, 264
Application Class
Web Development (CGI Library), 395
Applications
How to contribute?, 109
Applications developed in little hours
Analog Clock, 5
FetchStockData Application, 3
Fifteen Puzzle Game, 3
Fifteen Puzzle Game 2, 7
Introduction, 1
Quotes about Ring, 1
Samples in this book, 8
Squares Puzzle Game, 4
TicTacToe Game, 4
Werdy Application, 6
apppath()
Stdlib Functions, 285
Arithmetic Operators
Operators, 135
Ascii()
Data Type, 192
Assert()
Eval() and Debugging, 218
Assignment Operators
Operators, 136
attributes()
Reflection and Meta-programming, 275
Better Call Command
What is new in Ring 1.2?, 90
Better Code Generator for Extensions
What is new in Ring 1.1?, 100
What is new in Ring 1.5?, 50
Better Documentation
What is new in Ring 1.1?, 100
Better Documentation Generator for Extensions
What is new in Ring 1.5?, 51
Better Functions
What is new in Ring 1.2?, 87
Better Loop|Exit Command
What is new in Ring 1.3?, 81
Better Natural Language Programming Support
What is new in Ring 1.1?, 92
Better Objects Library
What is new in Ring 1.5?, 37
Better Quality
What is new in Ring 1.2?, 90
What is new in Ring 1.5?, 59
Better Ring Notepad
What is new in Ring 1.2?, 87
What is new in Ring 1.3?, 77
What is new in Ring 1.5?, 28
1737
Ring Documentation, Release 1.5
Better RingQt
What is new in Ring 1.2?, 87
What is new in Ring 1.3?, 73
What is new in Ring 1.4.1?, 62
What is new in Ring 1.4?, 71
What is new in Ring 1.5?, 35
Better Scripts for Building from Source Code
What is new in Ring 1.4.1?, 60
Better StdLib
What is new in Ring 1.3?, 81
What is new in Ring 1.4.1?, 61
What is new in Ring 1.4?, 69
What is new in Ring 1.5?, 31
Better WebLib
What is new in Ring 1.4?, 69
What is new in Ring 1.5?, 32
binarydigits()
Stdlib Functions, 294
Bitwise Operators
Operators, 135
BraceError() Method
Natural Language Programming, 337
BraceExprEval Method
Natural Language Programming, 336
BraceStart and BraceEnd Methods
Natural Language Programming, 335
Branching
Control Structures, 138
Control Structures - Second Style, 145
Control Structures - Third Style, 148
BreakPoint
The Trace Library and the Interactive Debugger, 720
Building From Source Code
Building using CMake, 106
Building using MacOS X, 105
Building using Microsoft Windows, 102
Building using Ubuntu Linux, 103
Introduction, 101
Building Games For Android
Building the project, 479
Download Requirements and Update the Android
SDK, 478
Introduction, 477
Project Folder, 478
Building RingQt Applications for Mobile
Comments about developing for Android using
RingQt, 634
Download Requirements, 633
Install Qt for Android, 633
Introduction, 632
Update the Android SDK, 633
Building the project
Building Games For Android, 479
Building using CMake
Building From Source Code, 106
Building using MacOS X
Building From Source Code, 105
Building using Microsoft Windows
Building From Source Code, 102
Building using Ubuntu Linux
Building From Source Code, 103
Calculator Application
What is new in Ring 1.5?, 27
Call Functions
Functions - First Style, 155
Functions - Second Style, 159
Functions - Third Style, 163
callgc()
Low Level Functions, 698
Calling a function sharing the name with a method in the
current class
Scope Rules for Functions and Methods, 666
Can I connect to dbase/harbour database?
Frequently Asked Questions, 1716
Can Ring work on Windows XP?
Frequently Asked Questions, 1718
capitalized()
Stdlib Functions, 288
cfunctions()
Reflection and Meta-programming, 268
CGI Support
Command Line Options, 696
Change Focus
Desktop and Mobile Development, 594
Change Language Keywords
Syntax Flexibility, 668
Change Language Operators
Syntax Flexibility, 669
Change the ’=’ operator to ’is’
Natural Language Programming, 333
Change the Ring Keyword ’And’
Natural Language Programming, 331
Change the Ring Operator ’+’
Natural Language Programming, 332
Change: Basic Extensions are separated from RingVM
What is new in Ring 1.4?, 64
changestring()
Stdlib Functions, 297
Char()
Data Type, 192
ChDir() Function
System Functions, 214
Check Character
Data Type, 187
Check Data Type
Data Type, 186
Check Parameters Count
Index 1738
Ring Documentation, Release 1.5
Extension, 727
Check Parameters Type
Extension, 728
Classes and Objects
Object Oriented Programming, 249
Classes and their Methods to use the default events
Desktop and Mobile Development, 624
classes()
Reflection and Meta-programming, 272
classname()
Reflection and Meta-programming, 274
Clean Natural Code
Natural Language Programming, 338
Clearerr()
Files, 204
clock()
Date and Time, 182
Close Window Event
RingLibSDL, 424
ClosPerSecond()
Date and Time, 182
Code Generator
Adding code to the generated code, 740
Comments in configuration file, 742
Configuration file, 738
Configuration file for the Allegro library, 743
Configuration Files Examples, 756
Constants Type, 743
Defining Constants, 741
Determine Structure Members Types, 741
Enum and Numbers, 742
Executing code during code generation, 742
Filtering using Expressions, 742
function prototype, 738
Introduction, 737
Prefix for Functions Names, 740
Qt configuration file, 747
Register New Functions, 741
Threads Support, 745
Using configuration file that wrap C++ library, 747
Using the tool, 738
Wrap structures, 740
Wrapping C++ Classes, 746
CodeEditor Class
RingQt Classes Reference, 1659
Command Line Options
CGI Support, 696
Generate Object File, 697
Introduction, 682
No Run, 696
Performance, 696
Printing Final Intermediate Code, 691
Printing Instruction Operation Code, 696
Printing Intermediate Code, 689
Printing Rules, 685
Printing Tokens, 683
Comments about developing for Android using RingQt
Building RingQt Applications for Mobile, 634
Comments about evaluation
Control Structures - First Style, 143
Comments in configuration file
Code Generator, 742
Compact Syntax
Language Design, 19
Compiler and Virtual Machine (VM)
How to contribute?, 109
Compiler Errors
Reference, 1725
Composition
Object Oriented Programming, 252
Configuration file
Code Generator, 738
Configuration file for the Allegro library
Code Generator, 743
Configuration Files Examples
Code Generator, 756
Configure the Apache web server
Web Development (CGI Library), 347
Conflict between Class Attributes and Local Variables
Scope Rules, 652
Conflict between Global Variables and Class Attributes
Frequently Asked Questions, 1704
Scope Rules, 651
Conflict between self inside braces and self in the class
region
Scope Rules, 658
Constants Type
Code Generator, 743
Constructor methods in Ring
Frequently Asked Questions, 1700
Contact the Autor
Resources, 1736
Control Structures
Branching, 138
Looping, 149
Control Structures - First Style
Comments about evaluation, 143
Do Again Loop, 141
Exit, 141
Exit from two loops, 141
Exit/Loop inside sub functions, 142
For In Loop, 140
for in to modify lists, 140
For Loop, 139
Introduction, 137
Loop Command, 142
Looping, 139
Short-circuit evaluation, 142
Index 1739
Ring Documentation, Release 1.5
Step Option, 140
Switch Statement, 138
While Loop, 139
Control Structures - Second Style
Branching, 145
Exceptions, 147
For In Loop, 147
For Loop, 146
If Statement, 145
Introduction, 144
Looping, 146
Switch Statement, 145
Control Structures - Third Style
Branching, 148
Exceptions, 151
For In Loop, 151
For Loop, 150
If Statement, 148
Introduction, 147
Switch Statement, 148
While Loop, 149
Conversion
Data Type, 191
Conversion Class
Stdlib Classes, 318
Convert between Numbers and Bytes
What is new in Ring 1.4?, 68
Convert Letters Case
Strings, 176
Cookies
Web Development (CGI Library), 359
Copy Lists
Lists, 172
Copy()
Strings, 178
Could you explain the output of the StrCmp() function?
Frequently Asked Questions, 1707
Create Database
MySQL Functions, 233
Create Lists
Lists, 168
Create Table and Insert Data
MySQL Functions, 234
Create Window
RingLibSDL, 421
Create Zip File
RingZip, 405
Creating a Class for each Window in GUI applications
Scope Rules, 657
Creating Menubar
Desktop and Mobile Development, 539
Creating more than one window
Desktop and Mobile Development, 577
Creating Reports using the WebLib and the GUILib
Desktop and Mobile Development, 629
Creating StatusBar
Desktop and Mobile Development, 543
Creating the Game Window
Game Engine for 2D Games, 432
Creating Toolbar
Desktop and Mobile Development, 542
Creating Windows Installer
Distributing Ring Application, 681
CRUD Example using MVC
Web Development (CGI Library), 381
CurrentDir() Function
System Functions, 214
Data Type
Ascii(), 192
Char(), 192
Check Character, 187
Check Data Type, 186
Conversion, 191
Dec(), 192
Hex(), 192
Hex2str(), 193
Introduction, 185
IsAlNum(), 188
IsAlpha(), 188
IsCntrl(), 188
IsDigit(), 189
IsGraph(), 189
IsList(), 187
IsLower(), 189
IsNULL(), 187
IsNumber(), 186
IsPrint(), 189
IsPunct(), 190
IsSpace(), 190
IsString(), 186
IsUpper(), 190
IsXdigit(), 190
Number(), 191
Str2Hex(), 193
String(), 191
Type(), 187
Database, ModelBase & ControllerBase classes
Web Development (CGI Library), 389
DataType Class
Stdlib Classes, 317
Date and Time
AddDays(), 184
clock(), 182
ClosPerSecond(), 182
Date(), 182
DiffDays(), 184
EpochTime(), 184
Index 1740
Ring Documentation, Release 1.5
Introduction, 181
Time(), 182
TimeList(), 183
Date()
Date and Time, 182
DateTime Class
Stdlib Classes, 312
dayofweek()
Stdlib Functions, 295
Debug Class
Stdlib Classes, 316
Dec()
Data Type, 192
Decimals()
Mathematical Functions, 197
Declarative Programming
Declarative programming on the top of Object-
Oriented, 327
executing code after the end of object access, 327
Introduction, 323
More Beatiful Code, 328
Objects inside lists, 324
Return object by reference, 325
Declarative programming on the top of Object-Oriented
Declarative Programming, 327
Declare parameters
Functions - First Style, 156
Functions - Second Style, 160
Functions - Third Style, 164
Decrypt()
Security and Internet Functions, 247
Deep Copy
Variables, 133
Define Declarative Languages
Language Design, 22
Define Functions
Functions - First Style, 155
Functions - Second Style, 159
Functions - Third Style, 163
Define Natural Statements
Language Design, 20
Defining Commands
Using the Natural Library, 342
Defining commands using classes
Using the Natural Library, 345
Defining Constants
Code Generator, 741
Defining Variables and Variables Access
Scope Rules, 649
Delete Item From List
Lists, 169
Demo Programs
Introduction, 218
Language Shell, 219
Main Menu, 219
The Cards Game, 618
Designed for a clear goal
Language Design, 17
Desktop and Mobile Development
Adding Hyperlink to QLabel, 559
Change Focus, 594
Classes and their Methods to use the default events,
624
Creating Menubar, 539
Creating more than one window, 577
Creating Reports using the WebLib and the GUILib,
629
Creating StatusBar, 543
Creating Toolbar, 542
Dialog Functions, 584
Display Image using QLabel, 563
Display Scaled Image using QLabel, 572
Drawing using QPainter, 574
Dynamic Objects, 598
Inheritance from GUI Classes, 590
KeyPress and Mouse Move Events, 584
Menubar and StyleSheet Example, 564
Methods to use Events with Events Filter, 627
Movable Label Example, 580
Moving Objects using the Mouse, 586
New Classes names - Index Start from 1, 629
Notepad Application, 603
Other Widgets Events, 568
Playing Sound, 578
Printing using QPrinter, 576
QLineEdit Events and QMessageBox, 566
QMessagebox Example, 581
QVideoWidget and QMediaPlayer, 560
Regular Expressions, 595
RingQt Classes and their Qt Documentation, 629
Rotate Text, 592
Simple Client and Server Example, 596
The Cards Game, 618
The Difference between Qt and RingQt, 628
The First GUI Application, 529
Using Layout, 530
Using QCheckBox, 556
Using QComboBox Class, 538
Using QDateEdit, 551
Using QDesktopWidget Class, 591
Using QDial, 552
Using QDockWidget, 544
Using QFrame, 561
Using QInputDialog Class, 582
Using qLCDNumber, 579
Using QProgressBar, 548
Using QProgressBar and Timer, 571
Using QRadioButton and QButtonGroup, 557
Index 1741
Ring Documentation, Release 1.5
Using QSlider, 549
Using QSpinBox, 549
Using QTableWidget, 547
Using QTabWidget, 545
Using QTreeView and QFileSystemModel, 536
Using QTreeWidget and QTreeWidgetItem, 537
Using QWebView, 555
Using the QColorDialog Class, 578
Using the QFileDialog Class, 573
Using the QListWidget Class, 533
Using the QTextEdit Class, 532
Using the QTimer Class, 570
Weight History Application, 599
Determine Structure Members Types
Code Generator, 741
Dialog Functions
Desktop and Mobile Development, 584
DiffDays()
Date and Time, 184
Dir()
Files, 200
direxists()
Stdlib Functions, 297
Disable BreakPoints
The Trace Library and the Interactive Debugger, 720
Display Error Message
Extension, 728
Display Image
RingLibSDL, 421
Display Image using QLabel
Desktop and Mobile Development, 563
Display PNG Images
RingLibSDL, 422
Display Scaled Image using QLabel
Desktop and Mobile Development, 572
Display Transparent Images
RingLibSDL, 423
Display Warnings Option
What is new in Ring 1.2?, 90
Distributing Applications and Games for Mobile
Distributing Ring Application, 682
Distributing Applications for Microsoft Windows
Distributing Ring Application, 681
Distributing Ring Application
Creating Windows Installer, 681
Distributing Applications and Games for Mobile,
682
Distributing Applications for Microsoft Windows,
681
Introduction, 680
Protecting the Source Code, 681
Using C/C++ Compiler and Linker, 682
Do Again Loop
Control Structures - First Style, 141
Documentation
How to contribute?, 108
Download Requirements
Building RingQt Applications for Mobile, 633
Download Requirements and Update the Android SDK
Building Games For Android, 478
Download()
Security and Internet Functions, 248
Draw Rectangle
RingLibSDL, 422
Drawing Text
Game Engine for 2D Games, 433
Drawing using QPainter
Desktop and Mobile Development, 574
Drawing using RingOpenGL
Using RingOpenGL and RingFreeGLUT for 3D
Graphics, 483
Drawing, Animation and Input
Graphics and Game Programming, 408
Dynamic Attributes
Object Oriented Programming, 256
Dynamic Objects
Desktop and Mobile Development, 598
Dynamic Typing
Variables, 133
Editors Support
How to contribute?, 109
Embedding Ring in Ring
Embedding Ring in Ring, 722
Embedding Ring in Ring without sharing the State,
723
Serial Execution of Programs, 723
Embedding Ring in Ring without sharing the State
Embedding Ring in Ring, 723
What is new in Ring 1.3?, 83
Embedding Ring Language in C/C++ Programs
Introduction, 734
Ring State, 735
Ring State Functions, 735
Ring State Variables, 736
Encourage Organization
Language Design, 19
Encrypt()
Security and Internet Functions, 246
endswith()
Stdlib Functions, 291
Entering Items
Form Designer, 647
Enum and Numbers
Code Generator, 742
EpochTime()
Date and Time, 184
Stdlib Functions, 299
Index 1742
Ring Documentation, Release 1.5
Equality of functions
Functional Programming, 265
Eval()
Eval() and Debugging, 216
Eval() and Debugging
Assert(), 218
Eval(), 216
Introduction, 215
Raise(), 217
Try/Carch/Done, 216
evenorodd()
Stdlib Functions, 293
Events Code
Form Designer, 643
Example
Files, 206
Mathematical Functions, 194
Natural Language Programming, 330
Objects Library for RingQt Application, 636
Security and Internet Functions, 247
System Functions, 211
The Type Hints Library, 678
Example - The Trace Library
Low Level Functions, 714
Example - Using the Trace Functions
Low Level Functions, 710
Example about Sharing Names between Functions and
Methods
Scope Rules for Functions and Methods, 664
Exceptions
Control Structures - Second Style, 147
Control Structures - Third Style, 151
Execute Program Line by Line
The Trace Library and the Interactive Debugger, 719
Execute Query and Print Result
ODBC Functions, 227
executing code after the end of object access
Declarative Programming, 327
Executing code during code generation
Code Generator, 742
ExeFileName() Function
System Functions, 214
ExeFolder() Function
System Functions, 214
Exit
Control Structures - First Style, 141
Exit from two loops
Control Structures - First Style, 141
Exit/Loop inside sub functions
Control Structures - First Style, 142
Extension
Check Parameters Count, 727
Check Parameters Type, 728
Display Error Message, 728
Fopen() and Fclose() Implementation, 729
Function Prototype, 729
Function Structure, 727
Get Parameters Values, 728
Introduction, 724
Module Organization, 726
MySQL_Columns() Implementation, 732
Return Value, 728
RING API - list Functions, 730
RING API - String Functions, 732
ring_ext.c, 725
ring_ext.h, 725
Shared Libraries, 733
Sin() Implementation, 729
Extensions in C/C++
How to contribute?, 109
Extract Zip File
RingZip, 405
Facebook Login
RingLibCurl, 401
factorial()
Stdlib Functions, 289
factors()
Stdlib Functions, 293
Fclose()
Files, 201
Features
Introduction, 13
Feof()
Files, 204
Ferror()
Files, 204
FetchStockData Application
Applications developed in little hours, 3
Fexists()
Files, 206
Fflush()
Files, 202
Fgetc()
Files, 205
Fgetpos()
Files, 204
Fgets()
Files, 205
fibonacci()
Stdlib Functions, 290
Fifteen Puzzle Game
Applications developed in little hours, 3
Fifteen Puzzle Game 2
Applications developed in little hours, 7
File Class
Stdlib Classes, 314
File Hash
Index 1743
Ring Documentation, Release 1.5
Security and Internet Functions, 247
file2list()
Stdlib Functions, 291
Files
Clearerr(), 204
Dir(), 200
Example, 206
Fclose(), 201
Feof(), 204
Ferror(), 204
Fexists(), 206
Fflush(), 202
Fgetc(), 205
Fgetpos(), 204
Fgets(), 205
Fopen(), 201
Fputc(), 205
Fputs(), 205
Fread(), 206
Freopen(), 202
Fseek(), 203
Fsetpos(), 204
Ftell(), 203
Fwrite(), 206
Introduction, 198
Numbers and Bytes, 208
Perror(), 204
Read File using Read(), 200
Remove(), 201
Rename(), 201
Rewind(), 203
Tempfile(), 203
Tempname(), 203
Ungetc(), 205
Write file using Write(), 200
filter()
Stdlib Functions, 287
Filtering using Expressions
Code Generator, 742
Find SubString
Strings, 179
Find() and List of Objects
Object Oriented Programming, 257
First-Class Functions
Functional Programming, 263
First-Class Lists
Lists, 173
Flappy Bird 3000 Game
Game Engine for 2D Games, 459
Fopen()
Files, 201
Fopen() and Fclose() Implementation
Extension, 729
For In Loop
Control Structures - First Style, 140
Control Structures - Second Style, 147
Control Structures - Third Style, 151
for in to modify lists
Control Structures - First Style, 140
For Loop
Control Structures - First Style, 139
Control Structures - Second Style, 146
Control Structures - Third Style, 150
Form Designer
Entering Items, 647
Events Code, 643
Introduction, 640
Keyboard Shortcuts, 646
Menubar Designer, 646
More Samples and Tests, 648
Running Forms, 643
The Designer Windows, 642
The Properties, 642
Using Layouts, 648
What is new in Ring 1.3?, 84
Window Flags, 647
Fputc()
Files, 205
Fputs()
Files, 205
Frames Per Second
Using RingOpenGL and RingFreeGLUT for 3D
Graphics, 516
Fread()
Files, 206
Freopen()
Files, 202
Frequently Asked Questions
Can I connect to dbase/harbour database?, 1716
Can Ring work on Windows XP?, 1718
Conflict between Global Variables and Class At-
tributes, 1704
Constructor methods in Ring, 1700
Could you explain the output of the StrCmp() func-
tion?, 1707
Getter and Setter Methods, 1702
Goal of including the Main function in Ring, 1698
How can I disable maximize button and resize win-
dow?, 1714
How to add Combobox and other elements to the
cells of a QTableWidget?, 1721
How to Close a window then displaying another
one?, 1713
How to create a Modal Window?, 1713
How to create an array of buttons in GUI applica-
tions?, 1712
How to extend RingQt and add more classes?, 1718
How to get the current source file path?, 1705
Index 1744

More Related Content

PDF
The Ring programming language version 1.5 book - Part 31 of 31
PDF
The Ring programming language version 1.5.2 book - Part 179 of 181
PDF
The Ring programming language version 1.5.3 book - Part 191 of 194
PPT
The Kotlin Programming Language
PDF
The Ring programming language version 1.5.2 book - Part 173 of 181
PDF
The Ring programming language version 1.6 book - Part 189 of 189
PDF
Kotlin: Challenges in JVM language design
PPTX
Kotlin as a Better Java
The Ring programming language version 1.5 book - Part 31 of 31
The Ring programming language version 1.5.2 book - Part 179 of 181
The Ring programming language version 1.5.3 book - Part 191 of 194
The Kotlin Programming Language
The Ring programming language version 1.5.2 book - Part 173 of 181
The Ring programming language version 1.6 book - Part 189 of 189
Kotlin: Challenges in JVM language design
Kotlin as a Better Java

What's hot (20)

PDF
The Ring programming language version 1.6 book - Part 187 of 189
PDF
Dive into Pinkoi 2013
PDF
Stetl for INSPIRE Data Transformation
PDF
The Ring programming language version 1.5.2 book - Part 180 of 181
PDF
Kotlin Slides from Devoxx 2011
PDF
FTD JVM Internals
PPTX
Kotlin
PDF
5 Minute Intro to Stetl
PDF
Geospatial ETL with Stetl - GeoPython 2016
PDF
The Ring programming language version 1.5.1 book - Part 13 of 180
PDF
Taming Rich GML with Stetl - FOSS4G 2013 Nottingham
PDF
Kotlin advanced - language reference for android developers
PDF
Java Full Throttle
PDF
Learning Git with Workflows
PPTX
Language Design Trade-offs
PDF
The Ring programming language version 1.7 book - Part 17 of 196
PDF
Introduction to Go programming language
PPTX
Golang for OO Programmers
PDF
Preon (J-Fall 2008)
PDF
Kotlin boost yourproductivity
The Ring programming language version 1.6 book - Part 187 of 189
Dive into Pinkoi 2013
Stetl for INSPIRE Data Transformation
The Ring programming language version 1.5.2 book - Part 180 of 181
Kotlin Slides from Devoxx 2011
FTD JVM Internals
Kotlin
5 Minute Intro to Stetl
Geospatial ETL with Stetl - GeoPython 2016
The Ring programming language version 1.5.1 book - Part 13 of 180
Taming Rich GML with Stetl - FOSS4G 2013 Nottingham
Kotlin advanced - language reference for android developers
Java Full Throttle
Learning Git with Workflows
Language Design Trade-offs
The Ring programming language version 1.7 book - Part 17 of 196
Introduction to Go programming language
Golang for OO Programmers
Preon (J-Fall 2008)
Kotlin boost yourproductivity
Ad

Similar to The Ring programming language version 1.5 book - Part 30 of 31 (20)

PDF
The Ring programming language version 1.5.3 book - Part 186 of 194
PDF
The Ring programming language version 1.6 book - Part 181 of 189
PDF
The Ring programming language version 1.7 book - Part 89 of 196
PDF
The Ring programming language version 1.8 book - Part 92 of 202
PDF
The Ring programming language version 1.5.4 book - Part 177 of 185
PDF
The Ring programming language version 1.2 book - Part 77 of 84
PDF
The Ring programming language version 1.5.3 book - Part 14 of 184
PDF
The Ring programming language version 1.4.1 book - Part 2 of 31
PDF
The Ring programming language version 1.8 book - Part 18 of 202
PDF
The Ring programming language version 1.3 book - Part 81 of 88
PDF
The Ring programming language version 1.4 book - Part 2 of 30
PDF
The Ring programming language version 1.5.1 book - Part 4 of 180
PDF
The Ring programming language version 1.2 book - Part 4 of 84
PDF
The Ring programming language version 1.10 book - Part 18 of 212
PDF
The Ring programming language version 1.9 book - Part 20 of 210
PDF
The Ring programming language version 1.10 book - Part 106 of 212
PDF
The Ring programming language version 1.3 book - Part 4 of 88
PDF
The Ring programming language version 1.10 book - Part 99 of 212
PDF
The Ring programming language version 1.6 book - Part 6 of 189
PDF
The Ring programming language version 1.8 book - Part 6 of 202
The Ring programming language version 1.5.3 book - Part 186 of 194
The Ring programming language version 1.6 book - Part 181 of 189
The Ring programming language version 1.7 book - Part 89 of 196
The Ring programming language version 1.8 book - Part 92 of 202
The Ring programming language version 1.5.4 book - Part 177 of 185
The Ring programming language version 1.2 book - Part 77 of 84
The Ring programming language version 1.5.3 book - Part 14 of 184
The Ring programming language version 1.4.1 book - Part 2 of 31
The Ring programming language version 1.8 book - Part 18 of 202
The Ring programming language version 1.3 book - Part 81 of 88
The Ring programming language version 1.4 book - Part 2 of 30
The Ring programming language version 1.5.1 book - Part 4 of 180
The Ring programming language version 1.2 book - Part 4 of 84
The Ring programming language version 1.10 book - Part 18 of 212
The Ring programming language version 1.9 book - Part 20 of 210
The Ring programming language version 1.10 book - Part 106 of 212
The Ring programming language version 1.3 book - Part 4 of 88
The Ring programming language version 1.10 book - Part 99 of 212
The Ring programming language version 1.6 book - Part 6 of 189
The Ring programming language version 1.8 book - Part 6 of 202
Ad

More from Mahmoud Samir Fayed (20)

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

Recently uploaded (20)

PPTX
MYSQL Presentation for SQL database connectivity
PDF
Encapsulation theory and applications.pdf
PPTX
Cloud computing and distributed systems.
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Machine learning based COVID-19 study performance prediction
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Empathic Computing: Creating Shared Understanding
PPTX
A Presentation on Artificial Intelligence
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
cuic standard and advanced reporting.pdf
MYSQL Presentation for SQL database connectivity
Encapsulation theory and applications.pdf
Cloud computing and distributed systems.
“AI and Expert System Decision Support & Business Intelligence Systems”
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Machine learning based COVID-19 study performance prediction
Network Security Unit 5.pdf for BCA BBA.
Programs and apps: productivity, graphics, security and other tools
Review of recent advances in non-invasive hemoglobin estimation
Spectral efficient network and resource selection model in 5G networks
Encapsulation_ Review paper, used for researhc scholars
The Rise and Fall of 3GPP – Time for a Sabbatical?
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
The AUB Centre for AI in Media Proposal.docx
Empathic Computing: Creating Shared Understanding
A Presentation on Artificial Intelligence
MIND Revenue Release Quarter 2 2025 Press Release
Diabetes mellitus diagnosis method based random forest with bat algorithm
cuic standard and advanced reporting.pdf

The Ring programming language version 1.5 book - Part 30 of 31

  • 1. Ring Documentation, Release 1.5 • const char *getpairingFinishedEvent(void) 95.175 QBluetoothServer Class C++ Reference : http://doc.qt.io/qt-5/QBluetoothServer.html Parameters : QBluetoothServiceInfo::Protocol,QObject * Parent Class : QObject • void close(void) • QBluetoothServer::Error error(void) • bool hasPendingConnections(void) • bool isListening(void) • bool listen(QBluetoothAddress address, quint16 port) • QBluetoothServiceInfo listen_2(QBluetoothUuid uuid, QString serviceName)) • int maxPendingConnections(void) • QBluetoothSocket * nextPendingConnection(void) • QBluetooth::SecurityFlags securityFlags(void) • QBluetoothAddress serverAddress(void) • quint16 serverPort(void) • QBluetoothServiceInfo::Protocol serverType(void) • void setMaxPendingConnections(int numConnections) • void setSecurityFlags(QBluetooth::SecurityFlags security) • void seterrorEvent(const char *) • void setnewConnectionEvent(const char *) • const char *geterrorEvent(void) • const char *getnewConnectionEvent(void) 95.176 QBluetoothServiceDiscoveryAgent Class C++ Reference : http://doc.qt.io/qt-5/QBluetoothServiceDiscoveryAgent.html Parameters : QObject * Parent Class : QObject • QList<QBluetoothServiceInfo> discoveredServices(void) • QBluetoothServiceDiscoveryAgent::Error error(void) • QString errorString(void) • bool isActive(void) • QBluetoothAddress remoteAddress(void) • bool setRemoteAddress(QBluetoothAddress address) 95.175. QBluetoothServer Class 1686
  • 2. Ring Documentation, Release 1.5 • void setUuidFilter(QList<QBluetoothUuid> uuids) • void setUuidFilter_2(QBluetoothUuid uuid) • QList<QBluetoothUuid> uuidFilter(void) • void clear(void) • void start(QBluetoothServiceDiscoveryAgent::DiscoveryMode mode) • void stop(void) • void setcanceledEvent(const char *) • void seterrorEvent(const char *) • void setfinishedEvent(const char *) • void setserviceDiscoveredEvent(const char *) • const char *getcanceledEvent(void) • const char *geterrorEvent(void) • const char *getfinishedEvent(void) • const char *getserviceDiscoveredEvent(void) 95.177 QBluetoothServiceInfo Class C++ Reference : http://doc.qt.io/qt-5/QBluetoothServiceInfo.html Parameters : void • QVariant attribute(quint16 attributeId) • QList<quint16> attributes(void) • bool contains(quint16 attributeId) • QBluetoothDeviceInfo device(void) • bool isComplete(void) • bool isRegistered(void) • bool isValid(void) • QBluetoothServiceInfo::Sequence protocolDescriptor(QBluetoothUuid::ProtocolUuid protocol) • int protocolServiceMultiplexer(void) • bool registerService(QBluetoothAddress localAdapter)) • void removeAttribute(quint16 attributeId) • int serverChannel(void) • quint8 serviceAvailability(void) • QList<QBluetoothUuid> serviceClassUuids(void) • QString serviceDescription(void) • QString serviceName(void) • QString serviceProvider(void) 95.177. QBluetoothServiceInfo Class 1687
  • 3. Ring Documentation, Release 1.5 • QBluetoothUuid serviceUuid(void) • void setAttribute(quint16 attributeId, QVariant value) • void setAttribute_2(quint16 attributeId, QBluetoothUuid value) • void setAttribute_3(quint16 attributeId, QBluetoothServiceInfo::Sequence value) • void setDevice(QBluetoothDeviceInfo device) • void setServiceAvailability(quint8 availability) • void setServiceDescription(QString description) • void setServiceName(QString name) • void setServiceProvider(QString provider) • void setServiceUuid(QBluetoothUuid uuid) • bool unregisterService(void) 95.178 QBluetoothSocket Class C++ Reference : http://doc.qt.io/qt-5/QBluetoothSocket.html Parameters : QBluetoothServiceInfo::Protocol,QObject * Parent Class : QIODevice • void abort(void) • void connectToService(QBluetoothServiceInfo service, QIODevice::OpenMode openMode) • void connectToService_2(QBluetoothAddress address, QBluetoothUuid uuid, QIODevice::OpenMode open- Mode) • void connectToService_3(QBluetoothAddress address, quint16 port, QIODevice::OpenMode openMode) • void disconnectFromService(void) • QBluetoothSocket::SocketError error(void) • QString errorString(void) • QBluetoothAddress localAddress(void) • QString localName(void) • quint16 localPort(void) • QBluetoothAddress peerAddress(void) • QString peerName(void) • quint16 peerPort(void) • bool setSocketDescriptor(int socketDescriptor, QBluetoothServiceInfo::Protocol socketType, QBluetooth- Socket::SocketState socketState, QIODevice::OpenMode openMode) • int socketDescriptor(void) • QBluetoothServiceInfo::Protocol socketType(void) • QBluetoothSocket::SocketState state(void) • void setconnectedEvent(const char *) 95.178. QBluetoothSocket Class 1688
  • 4. Ring Documentation, Release 1.5 • void setdisconnectedEvent(const char *) • void seterrorEvent(const char *) • void setstateChangedEvent(const char *) • const char *getconnectedEvent(void) • const char *getdisconnectedEvent(void) • const char *geterrorEvent(void) • const char *getstateChangedEvent(void) 95.179 QBluetoothTransferManager Class C++ Reference : http://doc.qt.io/qt-5/QBluetoothTransferManager.html Parameters : QObject * Parent Class : QObject • QBluetoothTransferReply * put(QBluetoothTransferRequest request, QIODevice *data) • void setfinishedEvent(const char *) • const char *getfinishedEvent(void) 95.180 QBluetoothTransferReply Class C++ Reference : http://doc.qt.io/qt-5/QBluetoothTransferReply.html Parameters : QObject * Parent Class : QObject • QBluetoothTransferManager * manager(void) • QBluetoothTransferRequest request(void) • void abort(void) • void seterrorEvent(const char *) • void setfinishedEvent(const char *) • void settransferProgressEvent(const char *) • const char *geterrorEvent(void) • const char *getfinishedEvent(void) • const char *gettransferProgressEvent(void) 95.181 QBluetoothTransferRequest Class C++ Reference : http://doc.qt.io/qt-5/QBluetoothTransferRequest.html Parameters : QBluetoothAddress • QBluetoothAddress address(void) 95.179. QBluetoothTransferManager Class 1689
  • 5. Ring Documentation, Release 1.5 • QVariant attribute(QBluetoothTransferRequest::Attribute code, QVariant defaultValue)) • void setAttribute(QBluetoothTransferRequest::Attribute code, QVariant value) 95.182 QBluetoothUuid Class C++ Reference : http://doc.qt.io/qt-5/QBluetoothUuid.html Parameters : void Parent Class : QUuid • int minimumSize(void) • quint16 toUInt16(bool *ok) • quint32 toUInt32(bool *ok) • quint128 toUInt128(void) • QString characteristicToString(QBluetoothUuid::CharacteristicType uuid) • QString descriptorToString(QBluetoothUuid::DescriptorType uuid) • QString protocolToString(QBluetoothUuid::ProtocolUuid uuid) • QString serviceClassToString(QBluetoothUuid::ServiceClassUuid uuid) 95.182. QBluetoothUuid Class 1690
  • 6. CHAPTER NINETYSIX FREQUENTLY ASKED QUESTIONS (FAQ) 96.1 Why do we need Yet Another Programming Language (YAPL)? The language comes with better support for Natural Language Programming and Declarative Programming. The inno- vation comes in supporting these paradigms with new practical techniques on the top of Object-Oriented Programming and Functional Programming. Ring provide the programmers with the tools required to build a Natural Language like Supernova or Declarative Language like REBOL and QML without the need to know anything about (Compilers and Parsing). You get the language constructs ready for use to create domain-specific languages in a fraction of time. Check the Supernova programming language, In this language you can type (I want window and the window title is hello world.) and it will create a GUI window with “Hello, World!” as the window title. When I created Supernova language in 2010. I discovered that using the Natural Code can be (Like English without limits and we can get the human language power in programming) but to implement that You need a new language that are 1. General Purpose 2. Practical 3. Can create Natural Languages very quickly. So we can get a System that can increase ease of use and productivity to the maximum level. Ring is the best language to do that. So I created Ring to achieve this goal. Supernova was just a test for the idea. To get a near view about what are the Advantages and Disadvantages. After testing the new ideas you provide something practical. So we have Ring after Supernova. A story that maybe similar to having Python after ABC. Python avoid ABC problems but bring ABC advantages. Also Ring learn from Ruby and ROR story. The language power could appears in Frameworks better than direct usage as a general purpose language. Also Ring comes with a clear goal/motivation (Creating a new version of the PWCT Software) something learned from designing the C language to create the Unix Operating System. You have a goal that direct you in each design decision. You will understand the value of our decisions once you start trying to solve the problem that we will use Ring to solve. Could you enable any one in the world without knowledge about computer programming concepts to create very powerful software? In science the answer is (Visual Programming) and (Natural Programming). In practical we still away from switching to these paradigms without introducing other problems. Ring is designed to solve this problem. It’s designed to provide Natural Programming in a practical way. And to create a powerful Visual Programming tool. Ring is designed to be a new world of programming after 10 years of research in Visual Programming and Natural Languages. The Ring Programming Language (Compiler+VM) is developed 100% using Visual Programming without writing a single line of code. I used my tool (Programming Without Coding Technology) to design everything and get the C code generated for me. Advantages ? 1. More Faster 2. No Syntax Errors 1691
  • 7. Ring Documentation, Release 1.5 3. Easy to understand and manage the code because the Abstraction level is more higher 4. No Critical Disadvantages because you can control everything as writing your code. From my experience in using Visual Programming for 10 years and Natural Programming for 5 years I designed Ring to move the knowledge to mainstream programmers by providing a practical language that support these ideas. I agree that each programmer/developer has the freedom to form his opinions about any software including program- ming languages. Ring is not an exception but you may miss the idea behind the language. It’s innovative and may help you to think different about how to solve your problems. Maybe this is not clear to many programmers because It’s practical language and includes many features known to programmers and when a programmer look at a language he/she may think that nothing new because it’s familiar. I created Ring to solve problems in a different way. Where I will start programming just by describing the software using new natural interfaces that I will implement later when I move from the design stage to the implementation stage. (I don’t determine the time to switch between stages, You are free to use Agile methods). Since Ring is a new language you have 3 options. 1. Just don’t care. 2. Think in the future of the language and help us if you understand the idea and want to contribute. 3. Wait and come back again in the future to use it. Summary: • Ring is designed based on a need to develop a new version of the PWCT software. Once we finish PWCT 2.0 we will have good and large software developed using Ring. • We will push Declarative and Natural paradigms many steps forward. Also in next versions we have a plan to present a new paradigm for Network Programming and Concurrency. We tested this new paradigm through simple prototypes during the last years and we will integrate it with Ring in Future releases. 96.2 Why Ring is weakly typed? Because it’s more Natural, and Faster and this is important for the language goals. What comes first is what you want. When you type “Print : ” + 5 , The String comes first then 5 will be converted to a String. while when you type 5 + “10” The number comes first so “10” will be converted to 10. This help a lot to quickly convert between numbers and strings using the same operator. If you want to prevent conversion (Write code that prevent conversion) In these cases you will notice that what you are writing is less code (And can be removed). Weakly Typed = Automatic Conversion and Automatic is Good Thing and is better than Manual if you know how to use it correctly. 96.3 What are the advantages to using Ring over Lisp or Smalltalk? Smalltalk and Lisp are GREAT languages. I like many of the concepts behind them but I’m sure that selecting the right programming language is based on the problem and comes after the problem definition. I have a problem that I want to solve and these GREAT languages are not ideal for this problem so I designed Ring. When you design a new language, You can learn from the past but you must look forward and live in the Future. What you know about Natural Programming maybe based on the Old Knowledge about the power of these paradigms in the practical world and I agree with you but I see another techniques that can be applied to get this to work in practical. What you miss about Natural Language is that they are Context Sensitive and this means we can use it and think different about how we can express our ideas. example : I want window contains 3 buttons. 96.2. Why Ring is weakly typed? 1692
  • 8. Ring Documentation, Release 1.5 In one sentence I created 4 objects (The window and the three buttons) and added the buttons to the window. The idea of Natural Programming is to get many things done like that. 96.4 Why Ring is largely focussed on UI creation? Yes UI creation is one of the important things in the language features because it’s designed to create a visual pro- gramming tool, But the language is a multi-paradigm language where we can select the programming paradigm based on the problem. 96.5 Is Ring some sort of improvement over PHP? Ring is not designed to replace PHP, Lua and/or Smalltalk. And Ring support for Declarative Programming and Natural Language Programming is very innovative and much better than staying with Procedural, Object-Oriented and Functional Languages. Ring see the future in programming without code (Using Natural Languages) and is designed to support that. 96.6 What are the advantages to using Ring over native C or C++? Ring provides a better way to mix between different programming paradigms in solving problems. The different programming paradigms play well together in the same language. 1. It’s easy to switch from one programming paradigm to another one because the language constructs use similar syntax for similar concepts. 2. The paradigms are provided to interact and used together in different layers in the software. for example you can create a game engine using object-oriented programming but write the game code using declara- tive programming or natural programming and behind the scene your declarative or natural code will use the object- oriented classes. 3. Ring is very productive and natural programming language than C/C++ languages. 4. Ring is a dynamic language. We can generate and execute code during the runtime. We have dynamic typing and weakly typed language for flexibility. 5. The Garbage collector is generational (escape analysis) and also use reference counting. it’s very fast and still provide control to the programmer who can delete memory at any time. 6. Ring Compiler and Virtual Machine is just 15,000 lines of ANSI C code that can be compiled and used in any platform. 7. You can use C/C++ libraries and Ring comes with code generator to create wrappers from C functions or C++ classes. so when you need more performance or when you need to use more libraries you can easily do that. 96.7 What is the difference between Ring and Python? And is Ring Open Source? Yes the language is Free Open Source (MIT license) In general I like Python and Ruby but I was looking for a language more suitable for creating the next version of the Programming Without Coding Technology (PWCT) software so I started the Ring design. 96.4. Why Ring is largely focussed on UI creation? 1693
  • 9. Ring Documentation, Release 1.5 Some simple changes that matters for my goal are 1. Not case sensitive 2. The list index start from 1 3. You can call functions before definition 4. Don’t use Python syntax like (indentation, using self, :, pass & _) 5. Weakly typed (convert automatically between types based on context) 6. The programs follow simple and constant structure (Statements then functions then packages and classes) 7. Using the ‘=’ operator for assignment and for testing values Critical changes are 1. Small Language : The Ring compiler + Virtual Machine = 15K lines of C code , the other 500K lines are related to libraries and are optional when we go for using the language in C/C++ programs. 2. The Garbage collector : Uses Escape Analysis/Reference counting and give the programmer the ability to determine when to delete memory using the assignment operator 3. Compact Syntax : Ring is not line sensitive, you don’t need to write ; or press ENTER to separate between statements 4. Using { } to access the object then using the object attributes and methods directly 5. Natural Programming : It’s very easy to create natural interfaces using Ring based on OOP 6. Declarative Programming using Nested Structure The Ring programming language is designed based on my experience from using many other languages like C, C++, C#, Lua, PHP, Python, Ruby, Harbour, Basic and Supernova And the language comes with innovative features added to achieve the language goal • Applications programming language. • Productivity and developing high quality solutions that can scale. • Small and fast language that can be embedded in C/C++ projects. • Simple language that can be used in education and introducing Compiler/VM concepts. • General-Purpose language that can be used for creating domain-specific libraries, frameworks and tools. • Practical language designed for creating the next version of the Programming Without Coding Technology software. 96.8 What are the advantages to using Ring over Perl, PHP, Python or Ruby? 1. Ring is New and Innovative. The language will let you think different about programming. 2. Ring is Smaller. (Lessons learned from the Lua language) 3. Ring is Simple. (Lessons learned from the BASIC and Clipper/Harbour languages) 4. Ring is more Natural. (Lessons learned from the Supernova language) 5. Ring is more Declarative. (Lessons learned from REBOL and QML languages) 6. Ring Implementation is Transparent, Visual and comes with Rich Features. 96.8. What are the advantages to using Ring over Perl, PHP, Python or Ruby? 1694
  • 10. Ring Documentation, Release 1.5 96.9 What are the advantages to using Ring over Tcl or Lua? 1. Clean Code (More Natural) 2. More Features (A lot of useful programming paradigms) 96.10 What are the advantages to using Ring over C# or Java? 1. Compact Code (Clean and Natural), More Productivity and Flexibility. 2. Better support for Declarative Programming and Natural Programming 96.11 The documentation says functional programming is sup- ported, but then this happens? The question was about this code f = func { a = 42 return func { return a } } innerF = call f() call innerF() Output: Using uninitialized variable : a In function _ring_anonymous_func_16601() The Answer: • It’s Anonymous Functions, i.e. Not Closures. • Many developers asked about supporting Closures and during language development we may add new features that doesn’t go against the language goals or sprite. • You can use classes and objects when you want to merge between the state and functions to provide a clear solution. • You can use Lists and put the anonymous function inside the List then return the list that contains the state and the function. Pass the list to the function when you use it. • You can use eval() and substr() to add the variable value directly to the anonymous function before return. • We protect you from other scopes when you define the function. In Ring we provided the Three Scopes Rule where at each point you have only at maximum three scopes (Global, Object Scope and Local Scope). • We don’t get everything from everywhere to be like others! We don’t need to do that. If we will think like that then we will create a very complex language or we will save our time and use other languages. • When you think about learning or studying a new language concentrate about (What is new?) and (What is better in this language?) to know when to use it. Don’t compare a new language just released little months ago with languages started many years ago and expect to find everything that you used to have. • Each programming language miss features in other languages. The idea is not the Features. it’s the sprite and ability behind all of the features together. 96.9. What are the advantages to using Ring over Tcl or Lua? 1695
  • 11. Ring Documentation, Release 1.5 96.12 Why the ability to define your own languages Instead of just handing over the syntax so you can parse it using whatever code you like? It’s innovation - You create natural statements without the need to learn about parsing. You just use Classes which is intelligent decision (where later we can mix between classes to support more statements based on the context - We can change and translate the defined statements and many more!). Also the statements are added in Ring World where you can use any Ring statement. 96.13 Why you can specify the number of loops you want to break out of? The language supports programming in the small and programming in the large. The selection of what features to use is based on what are you going to do. Any programmer can write poorly code in any language if he/she wants to do that. The idea is what must be done in the language design to prevent errors without causing other problems like killing flexibility. Read some source code in the Linux Kernel and Ruby Implementation for example, You will find good usage for GOTO as a practical example that General Rules are not for All Use Cases and great programmers know when to break the rules. I’m not saying go and use GOTO or saying Ring add things like that. But the ability to break more than one loop and/or the ability to break the loop from sub functions is practical for small programs. Anyway these are some of the small new things added by the language (Not the big idea). 96.14 Why Ring uses ‘See’, ‘Give’, ‘But’ and ‘Ok’ Keywords? See and Give are selected not to be “opposite actions” but to reflect what I want to do as a programmer. When I want to see something on the screen I use ‘See’. When I want to give some input to the program I use ‘Give’. My selection of “but” and “ok” is based on selecting keywords that can be written quickly. Also using “but” is easy to remember than elseif/elif/elsif where each language select a different keyword. In Ring 1.1 and later versions All of this is just an option. You can use ‘Put’ and ‘Get’ instead of ‘See’ and ‘Give’ You can use ‘elseif’ and ‘end’ insetad of ‘But’ and ‘Ok’ It’s your choice. In Ring we have syntax flexibility where we provide more than one style. Also you can change the language keywords and operators. Also you can define new natural languages too. 96.15 What is the philosophy behind data types in Ring? The Ring programming language is designed to be SMALL. The language provides the basic constructs that you need to do anything! One of the goals is to keep the basic constructs simple and small as possible. 96.12. Why the ability to define your own languages Instead of just handing over the syntax so you can parse it using whatever code you like? 1696
  • 12. Ring Documentation, Release 1.5 Using Lists in Ring you can • Create Arrays (one data type) • Create Lists (Mix of data types) • Create Tree (Nested arrays) • Use String Index (Looks like Dictionary/Hash Table) The same principle is applied to Numbers • You can use the number for int value • You can use the number for double value • You can use the number for Boolean value (True/False) The sample principle is applied for Strings • You can use the string for storing one character • You can use the string for storing text (one or many lines) • You can use the string for storing binary data • You can use the string for storing date • You can use the string for storing time • You can use the string for storing NULL values (empty strings) And we have Object Oriented Support + Operator Overloading where the programmer can define new data types and use them as default types defined by the language So We have • A small and simple language that someone can pick in little days • A fast language that provide primitive types (String ? Number ? List ? Object) • A flexible language that can be extended using OOP to add new types according to the application domain 96.16 What about the Boolean values in Ring? You can use true for 1 and false for 0 when you test the result of Boolean expressions in your code. Just when you print the value using the see command you will see 1 for (true) and 0 for (false) Why ? Because Ring contains only 4 types of variables 1. Number 2. String 3. List 4. Object The first type (Number) is used to represent int, double and Boolean values. The second type (String) is used to represent char, array of characters, date and time. 96.16. What about the Boolean values in Ring? 1697
  • 13. Ring Documentation, Release 1.5 The third type (List) is used to represent Arrays of one type, Arrays of more than one type, Hash (Dictionary), Tree, etc. The object can be an object created from a Ring class (Any Class) or just a C Pointer that we get from calling a C/C++ function/method. Why ? The Ring is designed to give the programmer/developer the most simple constructs that can be used to do everything. The programmer/developer can customize the language by creating new classes (and use operator overloading) to get more types that he care about according to the problem domain. Why ? Because simple is better, and easy to learn and remember! And this provide flexibility to convert between high level types that can be represented using the same basic type 96.17 What is the goal of including the “Main” function in Ring? The main function is very important, you need it when you want to write statements that uses local variables instead of the Global scope. Example: x = 10 myfunc() See "X value = " + X # here I expect that x will be (10) # but I will get another value (6) because myfunc() uses x ! Func myfunc for x = 1 to 5 See x + nl next Output: 1 2 3 4 5 X value = 6 Now using the Main function Func Main x = 10 myfunc() See "X value = " + X Func myfunc for x = 1 to 5 See x + nl next Output 1 2 3 96.17. What is the goal of including the “Main” function in Ring? 1698
  • 14. Ring Documentation, Release 1.5 4 5 X value = 10 96.18 Why the list index start from 1 in Ring? It’s about how we count in the real world, when we have three apples in our hand we say 1 2 3 We don’t start from 0 The question must be why the other languages start from 0 ? The answer is, because this is related to the machine and how we deal with values and memory address. Example we have array called myarray[5] In memory : myarray will have an address The first item will be stored in that address The second item will come after that address and so on Now when we need to point to the first item we need the address of myarray So we type myarray[0] because myarray + 0 result will still point to the first item for the second item myarray[1] because myarray + 1 result will point to the second item and so on In Low Level languages or languages near to the machine it’s good to be like this But for high level language designed for applications it’s better to be natural Example mylist = [1,2,3,4,5] for x = 1 to len(mylist) see x + nl next In the previous example we start from 1 to the length of the array if the index starts from 0 we will write for x = 0 to len(mylist)-1 or remember the for loop in other languages for(x=0 ; x<nMax ; x++ ) You will use the < operator ! 96.19 Why Ring is not case-sensitive? 1. To be more human-friendly 2. Like Ada, SQL, Pascal, Delphi, Visual Basic, Visual FoxPro, etc. 3. To help in supporting Natural Language Programming. 96.18. Why the list index start from 1 in Ring? 1699
  • 15. Ring Documentation, Release 1.5 4. To be able to select your favorite style when writing the language keywords see "lower case!" SEE "UPPER case!" See "First Letter is UPPER case!" 5. To avoid getting error message when writing quick tests then type “variable” instead of “Variable”. 6. To avoid getting error message when you type “Dosomething()” instead of “doSomething()” 7. In Ring, No conflict between Variables, Method Names & Classes Names We can write person as variable name and Person as class name. person = new Person class Person name address phone 96.20 Why the Assignment operator uses Deep Copy? “Because it’s a poor tradeoff to add complexity for dubious performance gains, a good approach to deep vs. shallow copies is to prefer deep copies until proven otherwise.” , Steve McConnell, Code Complete 1. It’s more natural, When you use the assignment operator, You expect a deep copy. 2. If you don’t need a deep copy, Just don’t use it! 3. The Ring language is designed to reduce references usage as much as possible. 4. The Ring language is designed to make using references simple and possible in special cases where this make sense. 5. We have references when this is natural, like passing lists and objects to functions, creating objects (Like GUI Objects) from a C/C++ library, returning an object stored inside a list. 6. It is a feature, We can use it to create pure functions. The Value() function in the stdlib uses this feature to pass lists & objects by value when we need this. 7. When we need references, It’s recommended to create a class that manage sharing lists and objects. 8. It’s more safe at the application level to avoid many logical errors. 9. In Ring, we start without thinking about the little details and concentrate on the application, You don’t have to write the type (Dynamic Typing), You don’t have to write explicit conversions between numbers and strings (Weakly Typed) and you don’t have to select between using values or references, You don’t have to write the scope (Lexical Scoping). 10. In Ring, we have smart garbage collector (Simple & Fast), We can delete the memory directly at any time using the Assignment operator too. Reducing references usage or using them through managers helps a lot to achieve this goal. by doing this we have full control. 11. If you want to create references and avoid creating a manager, You can use Object2Pointer() and Pointer2Object() functio But It’s not the Ring way “Sprite” to do things. 96.20. Why the Assignment operator uses Deep Copy? 1700
  • 16. Ring Documentation, Release 1.5 96.21 Is there constructor methods in Ring? When you create new object for example new point 1 - Ring will allocate dynamic memory space to be used for the new object attributes that Ring doesn’t know anything about them. 2 - Ring will change the current local scope and the current object scope to use the object state created in step (1) 3 - Ring will move the execution to the class Region (After the class name and before any methods) 4 - Any Instructions/Code in the class region will be executed as any Ring code 5 - Control is moved from the class region to the location of (new point) once we reach the end of the class region or we uses a Return command. So All attributes that added to the object are dynamic attributes, this mean that you can control what attributes will be added through the runtime. Example: $3D = False see new point $3D = True see new point class point x y if not $3D return ok z Output: x: NULL y: NULL x: NULL y: NULL z: NULL You have an option to call init() method directly when you create a new object This method can do anything with the object attributes as it will be called after creating the object and executing the class region code. p1 = new point3d(100,200,300) see p1 class point3d x y z func init p1,p2,p3 x=p1 y=p2 z=p3 96.22 What happens when we create a new object? 1- When you create an object, the class region code will be executed and you will have the object attributes based on the code in that region 96.21. Is there constructor methods in Ring? 1701
  • 17. Ring Documentation, Release 1.5 2- Ring don’t care about the object methods until you start calling a method 3- When you call a method, Ring will check the object class and the class parent (if you are using inheritance) and will collect the methods for you to be used now or later from any object that belong to the same class. 4- Since methods are dynamic and each object get the method from the class, you can after creating objects, add new methods and use it with the object or any object created or will be created from the same class. Example: o1 = new point {x=10 y=20 z=30} o2 = new point {x=100 y=200 z =300} addmethod(o1,"print", func { see x + nl + y + nl + z + nl } ) o1.print() o2.print() class point x y z Output: 10 20 30 100 200 300 96.23 Can we use the attributes by accessing the Getter and Setter methods? Yes we can, The setter/getter methods are called automatically when you start using the attributes from outside the class Also you can call the methods instead of using the attributes. It’s your choice. Example: o1 = new Developer o1.name = "Mahmoud" see o1.name + nl o1 { name = "Gal" see name } o1 { name = "Bert" see name } o1.setname("Marino") see o1.getname() Class Developer name language = "Ring Programming Language" func setname value see "Message from SetName() Function!" + nl name = value + " - " + language func getname see "Message from GetName() Function!" + nl + nl return "Mr. " + name + nl Output 96.23. Can we use the attributes by accessing the Getter and Setter methods? 1702
  • 18. Ring Documentation, Release 1.5 Message from SetName() Function! Message from GetName() Function! Mr. Mahmoud - Ring Programming Language Message from SetName() Function! Message from GetName() Function! Mr. Gal - Ring Programming Language Message from SetName() Function! Message from GetName() Function! Mr. Bert - Ring Programming Language Message from SetName() Function! Message from GetName() Function! Mr. Marino - Ring Programming Language 96.24 Why should a search of global names be made while defining the class attributes? The question is why we don’t avoid conflicts with global variable names when we define the class attributes ? At first remember that using the optional $ mark in the global variables names solve the problem. Also using the Main function and avoiding global variables may help. The Answer: Ring is a dynamic language We can in the run-time determine the class attributes (Add/Remove) We can execute (any code) while defining the class attributes Example (1) oPerson = new Person Class Person See "Welcome to the Ring language" Example (2) Customize attributes based on global variable value $debug = true oPerson = new Person see oPerson Class Person if $debug date=date() time=time() ok In the previous example when we have the $debug flag set to true, we will add the Date and Time attributes to the object state. Example (3) Store the object index based on global variable 96.24. Why should a search of global names be made while defining the class attributes? 1703
  • 19. Ring Documentation, Release 1.5 $ObjectsCount = 0 oPerson = new Person see oPerson oPerson2 = new Person see oPerson2 Class Person $ObjectsCount++ nIndex = $ObjectsCount Output: nindex: 1.000000 nindex: 2.000000 Common Example: • Connect to the database then get table columns (Using global Variable/Object). • Create class attributes based on the column names. • Later when you modify the database - you may don’t need to modify your code. It’s flexibility but remember that power comes with great responsibility. 96.25 Why Ring doesn’t avoid the conflict between Global Variables and Class Attributes Names? In this use case we have 1 - Global Variable defined without a special mark like $ 2 - Class contains Attributes defined using a special syntax (where we type the attribute name directly after the class) 3 - The Attributes are defined in the class region that allows writing code and using global variables If I will accepted your proposal about changing how Ring find variables in the class region I must break one of the previous three features which will lead to more problems that are more important than this problem. I don’t like changing the feature number (1) because I would like to keep Ring code more clean and let the programmer decide when to use $ or not. I don’t like changing the feature number (2) because I like this feature and I don’t like forcing the programmer to type self.attribute I don’t like changing the feature number (3) because it’s very important in many applications to access global variables in the class region. So what was my decision ? I decided to leave this case for the programmer who will decide what to do to avoid this special case 1 - The programmer can avoid using global variables (Better) and can use the Main function (Optional) 2 - The programmer can use $ before the variable name or any mark like global_ or g_ 3 - The programmer can use self.attribute after the class name to define the attributes In general, for small programs you can use global variables and functions. For large programs, use classes and objects and small number of global variables or avoid them at all. 96.25. Why Ring doesn’t avoid the conflict between Global Variables and Class Attributes Names?1704
  • 20. Ring Documentation, Release 1.5 96.26 Where can I write a program and execute it? Run the Ring Notepad where you can write/execute programs. If you want to run programs using the command line Add Ring/bin folder to the path then 96.27 How to get the file size using ftell() and fseek() functions? The next function can be used to get the file size without reading the file! func getFileSize fp C_FILESTART = 0 C_FILEEND = 2 fseek(fp,0,C_FILEEND) nFileSize = ftell(fp) fseek(fp,0,C_FILESTART) return nFileSize Note: The previous function take the fp (file pointer) as parameter, We can get the fp from opening the file using fopen() function. fp = fopen("filename","r") see "File Size : " + getFileSize(fp) + nl Another solution (Read the file) see len(read("filename")) 96.28 How to get the current source file path? We can use the next function to get the current source file path then we can add the path variable to the file name cPath = CurrentPath() func currentpath cFileName = filename() for x = len(cFileName) to 1 step -1 if cFileName[x] = "/" return left(cFileName,x-1) ok next return cFileName 96.29 What about predefined parameters or optional parameters in functions? if you want to use predefined parameters or optional parameters Just accept a list that works like hash/dictionary Example 96.26. Where can I write a program and execute it? 1705
  • 21. Ring Documentation, Release 1.5 sum([ :a = 1, :b = 2]) sum([ :a = 1 ]) sum([ :b = 2 ]) func sum pList if plist[:a] = NULL pList[:a] = 4 ok if plist[:b] = NULL pList[:b] = 5 ok see pList[:a] + pList[:b] + nl Output 3 6 6 96.30 How to print keys or values only in List/Dictionary? If you want to print keys only or values only just select the index of the item (one or two). Example C_COUNTRY = 1 C_CITY = 2 mylist = [ :KSA = "Riyadh" , :Egypt = "Cairo" ] for x in mylist see x[C_COUNTRY] + nl next for x in mylist see x[C_CITY] + nl next Output ksa egypt Riyadh Cairo 96.31 Why I get a strange result when printing nl with lists? In the next code list = 1:5 # list = [1,2,3,4,5] see list + nl New Line will be added to the list then the list will be printed, the default print of the lists will print a newline at the end, You added new newline and You have now 2 newlines to be printed. See <Expr> The see command just print the final result of the expression, the expression will be evaluated as it 96.30. How to print keys or values only in List/Dictionary? 1706
  • 22. Ring Documentation, Release 1.5 nl = char(13) + char(10) # just a variable that you can change to anything ! The + is an operator string + string ---> new string string + number ---> new string number + number ---> new number number + string ---> new number list + item —> nothing new will be created but the item will be added to the same list Exception number + nl ?> New String This exception is added to easily print numbers then new line. No need for this with printing lists because after printing the last item we already get a new line. 96.32 Could you explain the output of the StrCmp() function? At first remember that you can check strings using ‘=’ operator directly. see strcmp("hello","hello") + nl + strcmp("abc","bcd") + nl + strcmp("bcd","abc") + nl if the two strings are the same then it returns 0 abc and bcd aren’t the same. in the second line it returns -1 and in the third line it returns 1 In the second line we compare between “abc” and “bcd” Not equal because the first letter in “abc” = “a” and the first letter in “bcd” = “b” So we have “a” != “b” and “a” < “b” So we get output = -1 In the third line we have “bcd” and “abc” the first letter in “bcd” is “b” and the first letter in “abc” is “a” So we have “b” != “a” and “b” > “a” So we get output = 1 Note: ASCII(“a”) = 97 and ASCII(“b”) = 98 So “a” < “b” because 97 < 98 96.33 How to use many source code files in the project? Example: I have the next folder C:LRing Contains the next files 96.32. Could you explain the output of the StrCmp() function? 1707
  • 23. Ring Documentation, Release 1.5 C:LRingt1.ring C:LRingmylib.ring C:LRinglibsmylib2.ring The file t1.ring contains the next code load "mylib.ring" load "libsmylib2.ring" myfunc() test() The file mylib.ring contains the next code func myfunc see "message from myfunc"+nl The file libsmylib2.ring contains the next code func test see "message from test" + nl from the folder C:LRing If Ring is not added to the path you can add it or use the next command set path=%path%;c:ringbin; Where c:ring is the Ring folder Now run Ring t1.ring Output message from myfunc message from test 96.34 Why this example use the GetChar() twice? The GetChar() function accept one character from the keyboard buffer In this example While True See " Main Menu (1) Say Hello (2) Exit " Option = GetChar() GetChar() GetChar() # End of line # the previous two lines can be replaced with the next line # Give Option if Option = 1 see "Enter your name : " give cName see "Hello " + cName else 96.34. Why this example use the GetChar() twice? 1708
  • 24. Ring Documentation, Release 1.5 bye ok End We uses GetChar() Three times The first time we get the user option Option = GetChar() But in the second and the third times (We accept the new line characters from the buffer) GetChar() GetChar() # End of line Example : when the user select the option number 1 then press ENTER We have Three Characters • The first character is : Number 1 • The second character is : CHAR(13) • The third character is : CHAR(10) Because Windows uses CHAR(13) and CHAR(10) for each new line ( i.e. CR+LF ) 96.35 How to use NULL and ISNULL() function? when we try to use uninitialized variable in the Ring programming language, we get a clear runtime error message Example See x Output Line 1 Error (R24) : Using uninitialized variable : x in file testsseeuninit.ring The same happens when you try to access uninitialized attributes Example o1 = new point see o1 see o1.x class point x y z Output x: NULL y: NULL z: NULL Line 3 Error (R24) : Using uninitialized variable : x in file testsseeuninit2.ring if you want to check for the error, just use Try/Catch/End 96.35. How to use NULL and ISNULL() function? 1709
  • 25. Ring Documentation, Release 1.5 Try see x Catch See "Sorry, We can't use x!" + nl Done Output Sorry, We can't use x! Now we will talk about NULL and ISNULL() Since we get error message when we deal with uninitialized variables We can check these errors using Try/Catch/Done, So we uses NULL and ISNULL() for dealing with Strings. NULL is a variable contains an empty string ISNULL() is a function that returns true (1) if the input is an empty string or just a string contains “NULL” This because we need to test these values (empty strings) and strings contains “NULL” that sometimes come from external resource like DBMS. Example See IsNull(5) + nl + # print 0 IsNull("hello") + nl + # print 0 IsNull([1,3,5]) + nl + # print 0 IsNull("") + nl + # print 1 IsNull("NULL") # print 1 96.36 How to print lists that contains objects? In this example we will see how we can print a list contains objects. aList = [[1,2,3] , new point(1,2,3), new point(1,2,3)] see "print the list" + nl see alist see "print the item (object)" + nl see alist[2] class point x y z func init p1,p2,p3 x=p1 y=p2 z=p3 Output print the list 1 2 3 x: 1.000000 y: 2.000000 z: 3.000000 x: 1.000000 y: 2.000000 z: 3.000000 print the item (object) x: 1.000000 y: 2.000000 z: 3.000000 96.36. How to print lists that contains objects? 1710
  • 26. Ring Documentation, Release 1.5 96.37 How to insert an item to the first position in the list? To insert an item we can use the insert(aList,nIndex,Value) function. aList = 1:5 insert(aList,0,0) See aList # print numbers from 0 to 5 96.38 How to print new lines and other characters? To print new line we can use the nl variable. See "Hello" + nl or we can use multi-line literal as in the next example See "Hello " if we want to print other characters we can use the char(nASCII) function See char(109) + nl + # print m char(77) # print M 96.39 Why we don’t use () after the qApp class name? When we use RingQt to create GUI application, we uses () after the class name when we create new objects for example. new qWidget() { setWindowTitle("Hello World") resize(400,400) show() } but before doing that we create an object from the qApp class and we don’t use () after that Load "guilib.ring" app = new qApp { win=new qWidget() { setwindowtitle(:test) show() } exec() } Using () after the class name means calling the init() method in the class and passing parameters to this method. If we used () while no init() method in the class we get the expected error message. The class qApp don’t have this method while the other classes have it because they need it to create an object using a function that return a pointer to that object and this pointer will be stored in an attribute called pObject, for more information see ring_qt.ring file which contains the classes. 96.37. How to insert an item to the first position in the list? 1711
  • 27. Ring Documentation, Release 1.5 96.40 Why the window title bar is going outside the screen? When we write the next code Load "guilib.ring" app = new qApp { win=new qWidget() { setwindowtitle(:test) setGeometry(0,0,200,200) show() } exec() } I would expect that the window will run at the point (0,0) with (200,200) size but the actual result is that the window title bar is going outside the screen. This is related to the behavior of Qt framework. The next code will avoid the problem load "guilib.ring" new qApp { new qWidget() { move(0,0) resize(200,200) show() } exec() } 96.41 How to create an array of buttons in GUI applications? Check the next example: Load "guilib.ring" App1 = new qApp { win1 = new qWidget() { move(0,0) resize(500,500) new qPushButton(win1) { settext("OK") setclickevent("click()") } btn1 = new qPushButton(win1) { setgeometry(100,100,100,30) settext("Button1") } btn2 = new qPushButton(win1) { 96.40. Why the window title bar is going outside the screen? 1712
  • 28. Ring Documentation, Release 1.5 setgeometry(200,100,100,30) settext("Button2") } button = [btn1, btn2] show() } exec() } func click button[1] { settext ("Button3") } button[2] { settext ("Button4") } 96.42 How to Close a window then displaying another one? This example demonstrates how to close a window and show another one Load "guilib.ring" app=new qApp { frmBefore=new Qwidget() { setWindowTitle("before!") resize(300,320) move(200,200) button=new qPushButton(frmBefore) { setText("Close") setClickEvent("frmBefore.close() frmMain.show()") } show() } frmMain=new Qwidget() { setWindowTitle("After!") resize(300,320) move(200,200) } exec() } 96.43 How to create a Modal Window? This example demonstrates how to create a modal window 96.42. How to Close a window then displaying another one? 1713
  • 29. Ring Documentation, Release 1.5 load "guilib.ring" app=new qApp { frmStart=new Qwidget() { setWindowTitle("The First Window") resize(300,320) move(200,200) button=new qPushButton(frmStart) { setText("Show Modal Window") resize(200,30) setClickEvent("frmModal.show()") } new qPushButton(frmStart) { setText("Close Window") move(0,50) resize(200,30) setClickEvent("frmStart.Close()") } show() } frmModal =new Qwidget() { setWindowTitle("Modal Window") resize(300,320) move(200,200) setparent(frmStart) setwindowmodality(true) setwindowflags(Qt_Dialog) } exec() } Related Documents • http://doc.qt.io/qt-5/qtwidgets-widgets-windowflags-example.html • http://doc.qt.io/qt-5/qt.html#WindowType-enum • http://doc.qt.io/qt-5/qwindow.html#setParent • http://doc.qt.io/qt-5/qt.html#WindowModality-enum 96.44 How can I disable maximize button and resize window? Use the method setWindowFlags() Load "guilib.ring" app1 = new qapp { win1 = new qwidget() { 96.44. How can I disable maximize button and resize window? 1714
  • 30. Ring Documentation, Release 1.5 setwindowtitle("First") setgeometry(100,100,500,500) new qpushbutton(win1) { setgeometry(100,100,100,30) settext("close") setclickevent("app1.quit()") } new qpushbutton(win1) { setgeometry(250,100,100,30) settext("Second") setclickevent("second()") } showmaximized() } exec() } func second win2 = new qwidget() { setwindowtitle("Second") setgeometry(100,100,500,500) setwindowflags(Qt_dialog) show() } 96.45 How to use SQLite using ODBC? In Ring 1.1 and later versions we have native support for SQLite, so you don’t need to use it through ODBC. Also we can access SQLite through RingQt. The answer to your question pODBC = odbc_init() odbc_connect(pODBC,"DRIVER=SQLite3 ODBC Driver;Database=mydb.db;LongNames=0;"+ "Timeout=1000;NoTXN=0;SyncPragma=NORMAL;StepAPI=0;") odbc_execute(pODBC,"create table 'tel' ('ID','NAME','PHONE');") odbc_execute(pODBC,"insert into 'tel' values ('1','Mahmoud','123456');") odbc_execute(pODBC,"insert into 'tel' values ('2','Ahmed','123456');") odbc_execute(pODBC,"insert into 'tel' values ('3','Ibrahim','123456');") odbc_execute(pODBC,"select * from tel") + nl nMax = odbc_colcount(pODBC) See "Columns Count : " + nMax + nl while odbc_fetch(pODBC) See nl for x = 1 to nMax see odbc_getdata(pODBC,x) if x != nMax see " - " ok next end odbc_disconnect(pODBC) odbc_close(pODBC) Output: 96.45. How to use SQLite using ODBC? 1715
  • 31. Ring Documentation, Release 1.5 Columns Count : 3 1 - Mahmoud - 123456 2 - Ahmed - 123456 3 - Ibrahim - 123456 The program will create the file : mydb.db Note : when I print the odbc drivers I see the long list that includes SQLite3 ODBC Driver - UsageCount=1 SQLite ODBC Driver - UsageCount=1 SQLite ODBC (UTF-8) Driver - UsageCount=1 And I’m using “SQLite3 ODBC Driver”. 96.46 Can I connect to dbase/harbour database? You can connect to any database using ODBC To connect to xbase files (*.DBF) See "Using DBF Files using ODBC" + nl pODBC = odbc_init() See "Connect to database" + nl odbc_connect(pODBC,"Driver={Microsoft dBase Driver (*.dbf)};"+ "datasource=dBase Files;DriverID=277") See "Select data" + nl odbc_execute(pODBC,"select * from tel.dbf") nMax = odbc_colcount(pODBC) See "Columns Count : " + nMax + nl while odbc_fetch(pODBC) See "Row data:" + nl for x = 1 to nMax see odbc_getdata(pODBC,x) + " - " next end See "Close database..." + nl odbc_disconnect(pODBC) odbc_close(pODBC) Output Using DBF Files using ODBC Connect to database Select data Columns Count : 3 Row data: Ahmad - Egypt - 234567 - Row data: Fady - Egypt - 345678 - Row data: Shady - Egypt - 456789 - Row data: Mahmoud - Egypt - 123456 - Close database... Also you can connect to a Visual FoxPro database (requires installing Visual FoxPro driver) See "ODBC test 6" + nl pODBC = odbc_init() See "Connect to database" + nl 96.46. Can I connect to dbase/harbour database? 1716
  • 32. Ring Documentation, Release 1.5 odbc_connect(pODBC,"Driver={Microsoft Visual FoxPro Driver};"+ "SourceType=DBC;SourceDB=C:PWCT19ssbuildPWCTDATACH1Datamydata.dbc;") See "Select data" + nl see odbc_execute(pODBC,"select * from t38") + nl nMax = odbc_colcount(pODBC) See "Columns Count : " + nMax + nl while odbc_fetch(pODBC) See "Row data:" + nl for x = 1 to nMax see odbc_getdata(pODBC,x) + " - " next end See "Close database..." + nl odbc_disconnect(pODBC) odbc_close(pODBC) 96.47 Why setClickEvent() doesn’t see the object methods directly? setClickEvent(cCode) take a string contains code. The code will be executed when the event happens. Ring support Many Programming Paradigms like Procedural, OOP, Functional and others. But when you support many paradigms at the language level you can’t know which paradigm will be used so you have two options 1. Provide General Solutions that works with many programming paradigms. 2. Provide Many Specific solutions where each one match a specific paradigm. setClickEvent() and others belong to (General Solutions that works with many programming paradigms). You just pass a string of code that will be executed without any care about classes and objects. This code could be anything like calling a function, calling a method and setting variable value. Some other languages force you to use OOP and call methods for events. Also some other languages uses anonymous functions that may get parameters like the current object. Now we have the general solution (not restricted with any paradigm), In the future we may add specific solutions that match specific paradigms (OOP, Functional, Declarative and Natural). 96.48 Why I get Calling Function without definition Error? Each program follow the next order 1 - Loading Files 2 - Global Variables and Statements 3 - Functions 4 - Packages, Classes and Methods So what does that mean ? 1. **** No Functions comes After Classes **** 2. **** No command is required to end functions/methods/classes/packages **** Look at this example See "Hello" test() func test 96.47. Why setClickEvent() doesn’t see the object methods directly? 1717
  • 33. Ring Documentation, Release 1.5 see "message from the test function!" + nl class test In the previous example we have a function called test() so we can call it directly using test() In the next example, test() will become a method See"Hello" test() # runtime error message class test func test # Test() now is a method (not a function) see "message from the test method!" + nl The errors comes when you define a method then try calling it directly as a function. The previous program must be See"Hello" new test { test() } # now will call the method class test func test # Test() now is a method (not a function) see "message from the test method!" + nl 96.49 Can Ring work on Windows XP? Ring can work on Windows XP and load extensions without problems. Just be sure that the extension can work on Windows XP and your compiler version support that (modern compilers requires some flags to support XP) Check this topic https://blogs.msdn.microsoft.com/vcblog/2012/10/08/windows-xp-targeting-with-c-in-visual-studio- 2012/ For example, We added /link /SUBSYSTEM:CONSOLE,"5.01" To the batch file to support Windows XP See : https://github.com/ring-lang/ring/blob/master/src/buildvccomplete.bat 96.50 How to extend RingQt and add more classes? You have many options In general you can extend Ring using C or C++ code Ring from Ring code you can call C Functions or use C++ Classes & Methods This chapter in the documentation explains this part in the language http://ring- lang.sourceforge.net/doc/extension.html For example the next code in .c file can be compiled to a DLL file using the Ring library (.lib) #include "ring.h" RING_FUNC(ring_ringlib_dlfunc) { 96.49. Can Ring work on Windows XP? 1718
  • 34. Ring Documentation, Release 1.5 printf("Message from dlfunc"); } RING_API void ringlib_init(RingState *pRingState) { ring_vm_funcregister("dlfunc",ring_ringlib_dlfunc); } Then from Ring you can load the DLL file using LoadLib() function then call the C function that called dlfunc() as any Ring function. See "Dynamic DLL" + NL LoadLib("ringlib.dll") dlfunc() Output Dynamic DLL Message from dlfunc When you read the documentation you will know about how to get parameters like (strings, numbers, lists and objects) And how to return a value (any type) from you function. From experience, when we support a C library or C++ Library We discovered that a lot of functions share a lot of code To save our time, and to quickly generate wrappers for C/C++ Libraries to be used in Ring We have this code generator https://github.com/ring-lang/ring/blob/master/extensions/codegen/parsec.ring The code generator is just a Ring program < 1200 lines of Ring code The generator take as input a configuration file contains the C/C++ library information like Functions Prototype, Classes and Methods, Constants, Enum, Structures and members , etc. Then the generator will generate *.C File for C libraries (to be able to use the library functions) *.CPP File for C++ libraries (to be able to use C++ classes and methods) *.Ring File (to be able to use C++ classes as Ring classes) *.RH file (Constants) To understand how the generator work check this extension for the Allegro game programming library https://github.com/ring-lang/ring/tree/master/extensions/ringallegro At first we have the configuration file https://github.com/ring-lang/ring/blob/master/extensions/ringallegro/allegro.cf To write this file, i just used the Allegro documentation + the Ring code generator rules Then after executing the generator using this batch file https://github.com/ring-lang/ring/blob/master/extensions/ringallegro/gencode.bat or using this script https://github.com/ring-lang/ring/blob/master/extensions/ringallegro/gencode.sh 96.50. How to extend RingQt and add more classes? 1719
  • 35. Ring Documentation, Release 1.5 I get the generated source code file https://github.com/ring-lang/ring/blob/master/extensions/ringallegro/ring_allegro.c The generated source code file (ring_allegro.c) is around 12,000 Lines of code (12 KLOC) While the configuration file is less than 1 KLOC To build the library (create the DLL files) https://github.com/ring-lang/ring/blob/master/extensions/ringallegro/buildvc.bat Also you can check this extension for the LibSDL Library https://github.com/ring-lang/ring/tree/master/extensions/ringsdl After this know you should know about 1 - Writing the configuration file 2 - Using the Code Generator 3 - Building your library/extension 4 - Using your library/extension from Ring code Let us move now to you question about Qt We have RingQt which is just an extension to ring (ringqt.dll) You don’t need to modify Ring. 1. You just need to modify RingQt 2. Or extend Ring with another extension based on Qt (but the same Qt version) For the first option see the RingQt extension https://github.com/ring-lang/ring/tree/master/extensions/ringqt Configuration file https://github.com/ring-lang/ring/blob/master/extensions/ringqt/qt.cf To generate the source code https://github.com/ring-lang/ring/blob/master/extensions/ringqt/gencode.bat https://github.com/ring-lang/ring/blob/master/extensions/ringqt/gencode.sh https://github.com/ring-lang/ring/blob/master/extensions/ringqt/gencodeandroid.bat To build the DLL/so/Dylib files https://github.com/ring-lang/ring/blob/master/extensions/ringqt/buildmingw32.bat https://github.com/ring-lang/ring/blob/master/extensions/ringqt/buildgcc.sh https://github.com/ring-lang/ring/blob/master/extensions/ringqt/buildclang.sh Study RingQt Learn about the options that you have 1. wrapping a Qt class directly 2. Creating a new class then wrapping your new class 96.50. How to extend RingQt and add more classes? 1720
  • 36. Ring Documentation, Release 1.5 For the second option (in the previous two points or in the two points before that) You will create new classes in C++ code Then you merge these classes to RingQt or provide special DLL for them (your decision) If your work is general (will help others) just put it to RingQt. if your work is special (to specific application) just put it in another extension. 96.51 How to add Combobox and other elements to the cells of a QTableWidget? Check the next code Load "guilib.ring" New qApp { win1 = new qMainWindow() { setGeometry(100,100,1100,370) setwindowtitle("Using QTableWidget") Table1 = new qTableWidget(win1) { setrowcount(10) setcolumncount(10) setGeometry(0,0,800,400) setselectionbehavior(QAbstractItemView_SelectRows) for x = 1 to 10 for y = 1 to 10 item1 = new qtablewidgetitem("R"+X+"C"+Y) setitem(x-1,y-1, item1) next next cmb = new QComboBox(Table1) { alist = ["one","two","three","four","five"] for x in aList additem(x,0) next } setCellWidget(5, 5, cmb) } setcentralwidget(table1) show() } exec() } 96.52 How to perform some manipulations on selected cells in QTableWidget? Check the next sample Load "guilib.ring" New qApp { 96.51. How to add Combobox and other elements to the cells of a QTableWidget? 1721
  • 37. Ring Documentation, Release 1.5 win1 = new qMainWindow() { setGeometry(100,100,800,600) setwindowtitle("Using QTableWidget") Table1 = new qTableWidget(win1) { setrowcount(10) setcolumncount(10) setGeometry(10,10,400,400) for x = 1 to 10 for y = 1 to 10 item1 = new qtablewidgetitem("10") setitem(x-1,y-1,item1) next next } btn1 = new qPushButton(win1) { setText("Increase") setGeometry(510,10,100,30) setClickEvent("pClick()") } show() } exec() } func pClick for nRow = 0 to Table1.rowcount() - 1 for nCol = 0 to Table1.columncount() - 1 Table1.item(nRow,nCol) { if isSelected() setText( "" + ( 10 + text()) ) ok } next next 96.52. How to perform some manipulations on selected cells in QTableWidget? 1722
  • 38. CHAPTER NINETYSEVEN LANGUAGE REFERENCE In this chapter we will learn about • Language keywords • Language Functions • Compiler Errors • Runtime Errors • Language Grammar • Virtual Machine (VM) Instructions 97.1 Language Keywords Keywords Count : 49 • again • and • but • bye • call • case • catch • changeringkeyword • changeringoperator • class • def • do • done • else • elseif • end • exit 1723
  • 39. Ring Documentation, Release 1.5 • for • from • func • get • give • if • import • in • load • loadsyntax • loop • new • next • not • off • ok • on • or • other • package • private • put • return • see • step • switch • to • try • while • endfunc • endclass • endpackage 97.1. Language Keywords 1724
  • 40. Ring Documentation, Release 1.5 97.2 Language Functions Functions Count : 197 len() add() del() sysget() clock() lower() upper() input() ascii() char() date() time() filename() getchar() system() random() timelist() adddays() diffdays() version() clockspersecond() prevfilename() swap() shutdown() isstring() isnumber() islist() type() isnull() isobject() hex() dec() number() string() str2hex() hex2str() str2list() list2str() left() right() trim() copy() substr() lines() strcmp() eval() raise() assert() isalnum() isalpha() iscntrl() isdigit() isgraph() islower() isprint() ispunct() isspace() isupper() isxdigit() locals() globals() functions() cfunctions() islocal() isglobal() isfunction() iscfunction() packages() ispackage() classes() isclass() packageclasses() ispackageclass() classname() objectid() attributes() methods() isattribute() ismethod() isprivateattribute() isprivatemethod() addattribute() addmethod() getattribute() setattribute() mergemethods() packagename() ringvm_fileslist() ringvm_calllist() ringvm_memorylist() ringvm_functionslist() ringvm_classeslist() ringvm_packageslist() ringvm_cfunctionslist() ringvm_settrace() ringvm_tracedata() ringvm_traceevent() ringvm_tracefunc() ringvm_scopescount() ringvm_evalinscope() ringvm_passerror() ringvm_hideerrormsg() ringvm_callfunc() list() find() min() max() insert() sort() reverse() binarysearch() sin() cos() tan() asin() acos() atan() atan2() sinh() cosh() tanh() exp() log() log10() ceil() floor() fabs() pow() sqrt() unsigned() decimals() murmur3hash() fopen() fclose() fflush() freopen() tempfile() tempname() fseek() ftell() rewind() fgetpos() fsetpos() clearerr() feof() ferror() perror() rename() remove() fgetc() fgets() fputc() fputs() ungetc() fread() fwrite() dir() read() write() fexists() int2bytes() float2bytes() double2bytes() bytes2int() bytes2float() bytes2double() ismsdos() iswindows() iswindows64() isunix() ismacosx() islinux() isfreebsd() isandroid() windowsnl() currentdir() exefilename() chdir() exefolder() loadlib() closelib() callgc() varptr() intvalue() object2pointer() pointer2object() nullpointer() space() ptrcmp() ring_state_init() ring_state_runcode() ring_state_delete() ring_state_runfile() ring_state_findvar() ring_state_newvar() ring_state_runobjectfile() 97.3 Compiler Errors • Error (C1) : Error in parameters list, expected identifier • Error (C2) : Error in class name • Error (C3) : Unclosed control strucutre, ‘ok’ is missing • Error (C4) : Unclosed control strucutre, ‘end’ is missing • Error (C5) : Unclosed control strucutre, next is missing • Error (C6) : Error in function name 97.2. Language Functions 1725
  • 41. Ring Documentation, Release 1.5 • Error (C7) : Error in list items • Error (C8) : Parentheses ‘)’ is missing • Error (C9) : Brackets ‘]’ is missing • Error (C10) : Error in parent class name • Error (C11) : Error in expression operator • Error (C12) : No class definition • Error (C13) : Error in variable name • Error (C14) : Try/Catch miss the Catch keyword! • Error (C15) : Try/Catch miss the Done keyword! • Error (C16) : Error in Switch statement expression! • Error (C17) : Switch statement without OFF • Error (C18) : Missing closing brace for the block opened! • Error (C19) : Numeric Overflow! • Error (C20) : Error in package name • Error (C21) : Unclosed control strucutre, ‘again’ is missing • Error (C22) : Function redefinition, function is already defined! • Error (C23) : Using ‘(‘ after number! • Error (C24) : The parent class name is identical to the subclass name • Error (C25) : Trying to access the self reference after the object name” • Error (C26) : Class redefinition, class is already defined! 97.4 Runtime Errors • Error (R1) : Cann’t divide by zero ! • Error (R2) : Array Access (Index out of range) ! • Error (R3) : Calling Function without definition ! • Error (R4) : Stack Overflow ! • Error (R5) : Can’t access the list item, Object is not list ! • Error (R6) : Variable is required • Error (R7) : Can’t assign to a string letter more than one character • Error (R8) : Variable is not a string • Error (R9) : Using exit command outside loops • Error (R10) : Using exit command with number outside the range • Error (R11) : error in class name, class not found! • Error (R12) : error in property name, property not found! • Error (R13) : Object is required 97.4. Runtime Errors 1726
  • 42. Ring Documentation, Release 1.5 • Error (R14) : Calling Method without definition ! • Error (R15) : error in parent class name, class not found! • Error (R16) : Using braces to access unknown object ! • Error (R17) : error, using ‘Super’ without parent class! • Error (R18) : Numeric Overflow! • Error (R19) : Calling function with less number of parameters! • Error (R20) : Calling function with extra number of parameters! • Error (R21) : Using operator with values of incorrect type • Error (R22) : Using loop command outside loops • Error (R23) : Using loop command with number outside the range • Error (R24) : Using uninitialized variable • Error (R25) : Error in package name, Package not found! • Error (R26) : Calling private method from outside the class • Error (R27) : Using private attribute from outside the class • Error (R28) : Using bad data type as step value • Error (R29) : Using bad data type in for loop • Error (R30) : parent class name is identical to child class name • Error (R31) : Trying to destory the object using the self reference • Error (R32) : The CALL command expect a variable contains string! • Error (R33) : Bad decimals number (correct range >= 0 and <=14) ! • Error (R34) : Variable is required for the assignment operation • Error (R35) : Can’t create/open the file! • Error (R36) : The column number is not correct! It’s greater than the number of columns in the list • Error (R37) : Sorry, The command is not supported in this context • Error (R38) : Runtime Error in loading the dynamic library! 97.5 Language Grammar Program —> {statement} Statement —> ‘package’ <Identifier> { ‘.’ <Identifier> } [’{‘ {statement} ‘}’] [’end’|’endpackage’] Statement —> ‘class’ <Identifier> [ ‘from’|’:’|’<’ <Identifier> ] [’{‘ {statement} ‘}’][’end’|’endclass’] Statement —> ‘func’|’def’ <Identifier> [ParaList] [’{‘ {statement} ‘}’][’end’|’endfunc’] Statement —> ‘import’ <Identifier> { ‘.’ <Identifier> } Statement —> ‘private’ Statement —> ‘load’ <Literal> Statement —> ‘loadsyntax’ <Literal> 97.5. Language Grammar 1727
  • 43. Ring Documentation, Release 1.5 Statement —> ‘changeringkeyword’ <OldKeyword> <NewKeyword> Statement —> ‘changeringoperator’ <OldOperator> <NewOperator> Statement —> ‘see’|’put’ <Expr> Statement —> ‘give’|’get’ <Identifier> Statement —> ‘if’ <Expr> [’{‘] {statement} [ {‘but’|’elseif’ <Expr> {Statement} } ] [’else’ {Statement} ] ‘ok’|’end’|’}’ Statement —> ‘Switch’ <Expr> [’{‘] { ‘on’|’case’ <Expr> {statement} } [’other’ {Statement} ] ‘off’|’end’|’}’ Statement —> ‘for’ <Identifier> ‘=’ <Expr> ‘to’ <Expr> [ ‘step’ <Expr> ] [’{‘] {Statement} ‘next’|’end’|’}’ Statement —> ‘for’ <Identifier> ‘in’ <Expr> [ ‘step’ <Expr> ] [’{‘] {statement} ‘next’|’end’|’}’ Statement —> ‘while’ <Expr> [’{‘] {statement} ‘end’|’}’ Statement —> ‘do’ {statement} ‘again’ <Expr> Statement —> ‘try’ {statement} [’{‘] ‘catch’ {statement} ‘done’|’end’|’}’ Statement —> ‘return’ <Expr> Statement —> ‘bye’ Statement —> ‘exit’ Statement —> ‘loop’ Statement —> <Expr> Statement —> epslion ParaList —> epslion ParaList —> [’(‘] <Identifier> [{ ‘,’ <Identifier> }] [’)’] Expr —> <LogicNot> [{ ‘and’|’or’ <LogicNot> }] LogicNot –> [’not’] <EqualOrNot> EqualOrNot –> [ ‘=’|’!=’ ] <Compare> Compare —> <BitOrXor> [ { ‘<’ | ‘>’ | ‘<=’ | ‘>=’ <BitOrXor> } ] BitOrXor —> <BitAnd> [ { ‘|’ | ‘^’ <BitAnd> } ] BitAnd —> <BitShift> [ { ‘&’ <BitShift> } ] BitShift —> <Arithmetic> [ { ‘<<’ | ‘>>’ <Arithmetic> } ] Arithmetic —> <Term> [ { ‘+’ | ‘-‘ <Term> } ] Term —> <Range> [ { ‘*’ | ‘/’ | ‘%’ <Range> } ] Range —> <Factor> [ ‘:’ <Factor> ] Factor —> <Identifier> [ {Mixer} ] [ ‘=’ <Expr> ] Factor —> <Number> Factor —> <Literal> Factor —> ‘:’ <Identifier> Factor —> ‘-‘ <Expr> Factor —> ‘(‘ <Expr> ‘)’ 97.5. Language Grammar 1728
  • 44. Ring Documentation, Release 1.5 Factor —> <List> Factor —> ‘new’ <Identifier> Factor —> <AnonymousFunction> Factor —> ‘call’ <identifier> { ‘.’ <Identifier> } ‘(‘ <Parameters> ‘)’ List —> ‘[’ [ <Expr> { ‘,’ <Expr> } ] ‘]’ Mixer —> { ‘.’ <Identifier> } Mixer —> ‘[’ <Expr> ‘]’ Mixer —> ‘(‘ [ <Expr> [ { ‘,’ <Expr> }] ] ‘)’ Mixer —> ‘{‘ {Statement} ‘}’ AnonymousFunction —> ‘func’|’def’| [<ParaList>] ‘{‘ {Statement} ‘}’ 97.6 Virtual Machine (VM) Instructions Definitions :- • VM : Virtual Machine • Stack : VM Stack • IR : Instruction Register • PC : Program Counter • VP : Variable Pointer • Stack[nSize] : Last Item in the Stack (Last In - First Out) • VV : Variable Value (We have a Pointer to a variable, And we access this variable value) (Stack and Variables) 97.6. Virtual Machine (VM) Instructions 1729
  • 45. Ring Documentation, Release 1.5 Operation Description • ICO_PUSHC Add string from the IR to the stack • ICO_PUSHN Add number from the IR to the stack • ICO_PUSHV Replace VP in the stack[nSize] with the variable value • ICO_LOADADDRESS Read variable name from the IR, push VP to the stack • ICO_ASSIGNMENT Stack[nSize-1] VV = Stack[nSize] VV , POP Stack[nSize] • ICO_INC Increment Number in Stack[nSize] by 1 • ICO_LOADAPUSHV The same as ICO_LOADADDRESS then ICO_PUSHV • ICO_NEWLINE Store new line number (debug info) • ICO_FREESTACK Remove all items from the stack , nSize = 0 • ICO_FILENAME Store the source code file name (debug info) • ICO_FREELOADASCOPE Free the Scope List of the current Expression (Jump) Operation Description • ICO_JUMP Set PC to new value from the IR • ICO_JUMPZERO If Stack[nSize] is a number = 0 then Set PC to new value from the IR • ICO_JUMPFOR End of for loop • ICO_JUMPONE If Stack[nSize] is a number = 1 then Set PC to new value from the IR • ICO_JUMPZERO2 As ICO_JUMPZERO but add 1 to the stack (required for many ‘AND’ conditions) • ICO_JUMPONE2 As ICO_JUMPONE but add 1 to the stack (required for many ‘OR’ conditions) (Compare) 97.6. Virtual Machine (VM) Instructions 1730
  • 46. Ring Documentation, Release 1.5 Operation Description • ICO_LESSEQUAL If stack[nSize-1] <= stack[nSize] , POP stack[nSize], set Stack[nSize-1] = 1 else set Stack[nSize-1] = 0 • ICO_EQUAL If stack[nSize-1] = stack[nSize] , POP stack[nSize], set Stack[nSize-1] = 1 else set Stack[nSize-1] = 0 • ICO_LESS If stack[nSize-1] < stack[nSize] , POP stack[nSize], set Stack[nSize-1] = 1 else set Stack[nSize-1] = 0 • ICO_GREATER If stack[nSize-1] > stack[nSize] , POP stack[nSize], set Stack[nSize-1] = 1 else set Stack[nSize-1] = 0 • ICO_GREATEREQUAL If stack[nSize-1] >= stack[nSize] , POP stack[nSize], set Stack[nSize-1] = 1 else set Stack[nSize-1] = 0 • ICO_NOTEQUAL If stack[nSize-1] != stack[nSize] , POP stack[nSize], set Stack[nSize-1] = 1 else set Stack[nSize-1] = 0 (Math) Operation Description • ICO_SUM Stack[nSize-1] = Stack[nSize-1] + Stack[nSize] , POP stack[nSize] • ICO_SUB Stack[nSize-1] = Stack[nSize-1] - Stack[nSize] , POP stack[nSize] • ICO_MUL Stack[nSize-1] = Stack[nSize-1] * Stack[nSize] , POP stack[nSize] • ICO_DIV Stack[nSize-1] = Stack[nSize-1] / Stack[nSize] , POP stack[nSize] • ICO_MOD Stack[nSize-1] = Stack[nSize-1] % Stack[nSize] , POP stack[nSize] • ICO_NEG Stack[nSize] = - Stack[nSize-1] • ICO_PLUSPLUS Stack[nSize] = Stack[nSize] + 1 • ICO_MINUSMINUS Stack[nSize] = Stack[nSize] - 1 (Logic) Operation Description • ICO_AND Stack[nSize-1] = Stack[nSize-1] && Stack[nSize] , POP stack[nSize] • ICO_OR Stack[nSize-1] = Stack[nSize-1] || Stack[nSize] , POP stack[nSize] • ICO_NOT Stack[nSize] = ! Stack[nSize] (Lists) 97.6. Virtual Machine (VM) Instructions 1731
  • 47. Ring Documentation, Release 1.5 Operation Description • ICO_LISTSTART Start New List in Temp. Memory • ICO_LISTITEM Add List Item • ICO_LISTEND End List • ICO_LOADINDEXADDRESS Stack[nSize-1] = Stack[nSize-1] VV [ Stack[nSize] ] , POP stack[nSize] (Functions) Operation Description • ICO_LOADFUNC Find function • ICO_CALL Call function • ICO_RETURN Return from function • ICO_RETNULL Return NULl from function • ICO_RETFROMEVAL Return after eval() • ICO_RETITEMREF Return the list item reference - not the value • ICO_NEWFUNC Start new function • ICO_BLOCKFLAG Flag to determine where to jump later (after ICO_RETURN) • ICO_FUNCEXE Start executing function • ICO_ENDFUNCEXE End function execution • ICO_ANONYMOUS Anonymous function (User Interface) Operation Description • ICO_PRINT Print value to the standard output • ICO_GIVE Get input from the keyboard (End Program/Loop) 97.6. Virtual Machine (VM) Instructions 1732
  • 48. Ring Documentation, Release 1.5 Operation Description • ICO_BYE End execution of VM • ICO_EXITMARK Place to exit to from a loop • ICO_POPEXITMARK Remove exit mark • ICO_EXIT Break from one loop or more • ICO_LOOP Continue to next loop (For Better Performance) Operation Description • ICO_PUSHP Push pointer to the stack • ICO_INCP Increment variable value using pointer • ICO_PUSHPV Push value of variable using variable pointer • ICO_INCJUMP Increment then jump • ICO_INCPJUMP Increment using pointer then jump • ICO_JUMPVARLENUM Jump if variable value is <= numeric value • ICO_JUMPVARPLENUM Jump if variable value (using pointer) <= numeric value • ICO_LOADFUNCP Push function pointer • ICO_PUSHPLOCAL Push pointer to local variable • ICO_INCLPJUMP Increment value using pointer to local variable then jump • ICO_JUMPVARLPLENUM Jump if the variable value (using pointer) <= numeric value • ICO_INCPJUMPSTEP1 Increment value using variable pointer then jump (for loop step = 1) • ICO_JUMPVARPLENUMSTEP1 Increment value using variable pointer then jump (for loop step = 1) (Try-Catch-Done) 97.6. Virtual Machine (VM) Instructions 1733
  • 49. Ring Documentation, Release 1.5 Operation Description • ICO_TRY Start try region • ICO_DONE End try region (Duplicate and Range) Operation Description • ICO_DUPLICATE Duplicate stack value • ICO_RANGE Create list from value to value (OOP) Operation Description • ICO_NEWOBJ Create new object, get class name from the IR, push ob- ject pointer to the stack. • ICO_SETSCOPE Called after creating new object, set the active scope to be the object scope. • ICO_LOADSUBADDRESS Get object attribute, push the pointer to the stack. • ICO_LOADMETHOD Find object method • ICO_AFTERCALLMETHOD Used after calling a method - normal case • ICO_AFTERCALLMETHOD2 Used after calling a method - second case • ICO_NEWCLASS Start new class region • ICO_BRACESTART Open brace • ICO_BRACEEND End brace • ICO_IMPORT Import package • ICO_PRIVATE start private attributes region • ICO_SETPROPERTY set attribute value - check for setter. • ICO_CALLCLASSINIT call call init() method. (Other) 97.6. Virtual Machine (VM) Instructions 1734
  • 50. Ring Documentation, Release 1.5 Operation Description • ICO_SETREFERENCE Copy by reference • ICO_KILLREFERENCE Remove reference • ICO_ASSIGNMENTPOINTER Determine the left side variable • ICO_BEFOREEQUAL Determine operators like += , -= , ... etc (Bitwise Operators) Operation Description • ICO_BITAND Stack[nSize-1] = Stack[nSize-1] & Stack[nSize] , POP stack[nSize] • ICO_BITOR Stack[nSize-1] = Stack[nSize-1] | Stack[nSize] , POP stack[nSize] • ICO_BITXOR Stack[nSize-1] = Stack[nSize-1] ^ Stack[nSize] , POP stack[nSize] • ICO_BITNOT Stack[nSize] = ! Stack[nSize] • ICO_BITSHL Stack[nSize-1] = Stack[nSize-1] << Stack[nSize] , POP stack[nSize] • ICO_BITSHR Stack[nSize-1] = Stack[nSize-1] >> Stack[nSize] , POP stack[nSize] (For Step) Operation Description • ICO_STEPNUMBER Determine step number in for loop • ICO_POPSTEP POP step number from steps stack • ICO_LOADAFIRST Load the first address of variable name 97.6. Virtual Machine (VM) Instructions 1735
  • 51. CHAPTER NINETYEIGHT RESOURCES In this section you will find resources about the language 98.1 Ring Language Website For news about the language check the website http://ring-lang.net http://ring-lang.sf.net 98.2 Ring Group For questions use the Ring Group (English) https://groups.google.com/forum/#!forum/ring-lang 98.3 Contact the Authors Name : Eng. Mahmoud Samir Fayed Country : Egypt Email : msfclipper@yahoo.com Facebook : https://facebook.com/mahmoudfayed1986 LinkedIn : https://sa.linkedin.com/in/mahmoudfayed1986 Name : Dr. Atif M. Alamri Country : Saudi Arabia Email : atif@ksu.edu.sa LinkedIn : https://sa.linkedin.com/in/dr-atif-alamri-8b341747 Ring Team : http://ring-lang.sourceforge.net/team.html 1736
  • 52. INDEX Access List Items by String Index Lists, 174 Access Objects Using Braces Object Oriented Programming, 251 Access String Letters Strings, 176 Accessing the class attributes from braces inside class methods Scope Rules, 655 Add Items Lists, 168 addattribute() Reflection and Meta-programming, 278 AddDays() Date and Time, 184 Adding code to the generated code Code Generator, 740 Adding Hyperlink to QLabel Desktop and Mobile Development, 559 addmethod() Reflection and Meta-programming, 278 Analog Clock Applications developed in little hours, 5 Animate Class Game Engine for 2D Games, 432 Animate Events Game Engine for 2D Games, 443 Animation Game Engine for 2D Games, 437 Animation and Functions Game Engine for 2D Games, 438 Anonymous and Nested Functions Functional Programming, 264 Application Class Web Development (CGI Library), 395 Applications How to contribute?, 109 Applications developed in little hours Analog Clock, 5 FetchStockData Application, 3 Fifteen Puzzle Game, 3 Fifteen Puzzle Game 2, 7 Introduction, 1 Quotes about Ring, 1 Samples in this book, 8 Squares Puzzle Game, 4 TicTacToe Game, 4 Werdy Application, 6 apppath() Stdlib Functions, 285 Arithmetic Operators Operators, 135 Ascii() Data Type, 192 Assert() Eval() and Debugging, 218 Assignment Operators Operators, 136 attributes() Reflection and Meta-programming, 275 Better Call Command What is new in Ring 1.2?, 90 Better Code Generator for Extensions What is new in Ring 1.1?, 100 What is new in Ring 1.5?, 50 Better Documentation What is new in Ring 1.1?, 100 Better Documentation Generator for Extensions What is new in Ring 1.5?, 51 Better Functions What is new in Ring 1.2?, 87 Better Loop|Exit Command What is new in Ring 1.3?, 81 Better Natural Language Programming Support What is new in Ring 1.1?, 92 Better Objects Library What is new in Ring 1.5?, 37 Better Quality What is new in Ring 1.2?, 90 What is new in Ring 1.5?, 59 Better Ring Notepad What is new in Ring 1.2?, 87 What is new in Ring 1.3?, 77 What is new in Ring 1.5?, 28 1737
  • 53. Ring Documentation, Release 1.5 Better RingQt What is new in Ring 1.2?, 87 What is new in Ring 1.3?, 73 What is new in Ring 1.4.1?, 62 What is new in Ring 1.4?, 71 What is new in Ring 1.5?, 35 Better Scripts for Building from Source Code What is new in Ring 1.4.1?, 60 Better StdLib What is new in Ring 1.3?, 81 What is new in Ring 1.4.1?, 61 What is new in Ring 1.4?, 69 What is new in Ring 1.5?, 31 Better WebLib What is new in Ring 1.4?, 69 What is new in Ring 1.5?, 32 binarydigits() Stdlib Functions, 294 Bitwise Operators Operators, 135 BraceError() Method Natural Language Programming, 337 BraceExprEval Method Natural Language Programming, 336 BraceStart and BraceEnd Methods Natural Language Programming, 335 Branching Control Structures, 138 Control Structures - Second Style, 145 Control Structures - Third Style, 148 BreakPoint The Trace Library and the Interactive Debugger, 720 Building From Source Code Building using CMake, 106 Building using MacOS X, 105 Building using Microsoft Windows, 102 Building using Ubuntu Linux, 103 Introduction, 101 Building Games For Android Building the project, 479 Download Requirements and Update the Android SDK, 478 Introduction, 477 Project Folder, 478 Building RingQt Applications for Mobile Comments about developing for Android using RingQt, 634 Download Requirements, 633 Install Qt for Android, 633 Introduction, 632 Update the Android SDK, 633 Building the project Building Games For Android, 479 Building using CMake Building From Source Code, 106 Building using MacOS X Building From Source Code, 105 Building using Microsoft Windows Building From Source Code, 102 Building using Ubuntu Linux Building From Source Code, 103 Calculator Application What is new in Ring 1.5?, 27 Call Functions Functions - First Style, 155 Functions - Second Style, 159 Functions - Third Style, 163 callgc() Low Level Functions, 698 Calling a function sharing the name with a method in the current class Scope Rules for Functions and Methods, 666 Can I connect to dbase/harbour database? Frequently Asked Questions, 1716 Can Ring work on Windows XP? Frequently Asked Questions, 1718 capitalized() Stdlib Functions, 288 cfunctions() Reflection and Meta-programming, 268 CGI Support Command Line Options, 696 Change Focus Desktop and Mobile Development, 594 Change Language Keywords Syntax Flexibility, 668 Change Language Operators Syntax Flexibility, 669 Change the ’=’ operator to ’is’ Natural Language Programming, 333 Change the Ring Keyword ’And’ Natural Language Programming, 331 Change the Ring Operator ’+’ Natural Language Programming, 332 Change: Basic Extensions are separated from RingVM What is new in Ring 1.4?, 64 changestring() Stdlib Functions, 297 Char() Data Type, 192 ChDir() Function System Functions, 214 Check Character Data Type, 187 Check Data Type Data Type, 186 Check Parameters Count Index 1738
  • 54. Ring Documentation, Release 1.5 Extension, 727 Check Parameters Type Extension, 728 Classes and Objects Object Oriented Programming, 249 Classes and their Methods to use the default events Desktop and Mobile Development, 624 classes() Reflection and Meta-programming, 272 classname() Reflection and Meta-programming, 274 Clean Natural Code Natural Language Programming, 338 Clearerr() Files, 204 clock() Date and Time, 182 Close Window Event RingLibSDL, 424 ClosPerSecond() Date and Time, 182 Code Generator Adding code to the generated code, 740 Comments in configuration file, 742 Configuration file, 738 Configuration file for the Allegro library, 743 Configuration Files Examples, 756 Constants Type, 743 Defining Constants, 741 Determine Structure Members Types, 741 Enum and Numbers, 742 Executing code during code generation, 742 Filtering using Expressions, 742 function prototype, 738 Introduction, 737 Prefix for Functions Names, 740 Qt configuration file, 747 Register New Functions, 741 Threads Support, 745 Using configuration file that wrap C++ library, 747 Using the tool, 738 Wrap structures, 740 Wrapping C++ Classes, 746 CodeEditor Class RingQt Classes Reference, 1659 Command Line Options CGI Support, 696 Generate Object File, 697 Introduction, 682 No Run, 696 Performance, 696 Printing Final Intermediate Code, 691 Printing Instruction Operation Code, 696 Printing Intermediate Code, 689 Printing Rules, 685 Printing Tokens, 683 Comments about developing for Android using RingQt Building RingQt Applications for Mobile, 634 Comments about evaluation Control Structures - First Style, 143 Comments in configuration file Code Generator, 742 Compact Syntax Language Design, 19 Compiler and Virtual Machine (VM) How to contribute?, 109 Compiler Errors Reference, 1725 Composition Object Oriented Programming, 252 Configuration file Code Generator, 738 Configuration file for the Allegro library Code Generator, 743 Configuration Files Examples Code Generator, 756 Configure the Apache web server Web Development (CGI Library), 347 Conflict between Class Attributes and Local Variables Scope Rules, 652 Conflict between Global Variables and Class Attributes Frequently Asked Questions, 1704 Scope Rules, 651 Conflict between self inside braces and self in the class region Scope Rules, 658 Constants Type Code Generator, 743 Constructor methods in Ring Frequently Asked Questions, 1700 Contact the Autor Resources, 1736 Control Structures Branching, 138 Looping, 149 Control Structures - First Style Comments about evaluation, 143 Do Again Loop, 141 Exit, 141 Exit from two loops, 141 Exit/Loop inside sub functions, 142 For In Loop, 140 for in to modify lists, 140 For Loop, 139 Introduction, 137 Loop Command, 142 Looping, 139 Short-circuit evaluation, 142 Index 1739
  • 55. Ring Documentation, Release 1.5 Step Option, 140 Switch Statement, 138 While Loop, 139 Control Structures - Second Style Branching, 145 Exceptions, 147 For In Loop, 147 For Loop, 146 If Statement, 145 Introduction, 144 Looping, 146 Switch Statement, 145 Control Structures - Third Style Branching, 148 Exceptions, 151 For In Loop, 151 For Loop, 150 If Statement, 148 Introduction, 147 Switch Statement, 148 While Loop, 149 Conversion Data Type, 191 Conversion Class Stdlib Classes, 318 Convert between Numbers and Bytes What is new in Ring 1.4?, 68 Convert Letters Case Strings, 176 Cookies Web Development (CGI Library), 359 Copy Lists Lists, 172 Copy() Strings, 178 Could you explain the output of the StrCmp() function? Frequently Asked Questions, 1707 Create Database MySQL Functions, 233 Create Lists Lists, 168 Create Table and Insert Data MySQL Functions, 234 Create Window RingLibSDL, 421 Create Zip File RingZip, 405 Creating a Class for each Window in GUI applications Scope Rules, 657 Creating Menubar Desktop and Mobile Development, 539 Creating more than one window Desktop and Mobile Development, 577 Creating Reports using the WebLib and the GUILib Desktop and Mobile Development, 629 Creating StatusBar Desktop and Mobile Development, 543 Creating the Game Window Game Engine for 2D Games, 432 Creating Toolbar Desktop and Mobile Development, 542 Creating Windows Installer Distributing Ring Application, 681 CRUD Example using MVC Web Development (CGI Library), 381 CurrentDir() Function System Functions, 214 Data Type Ascii(), 192 Char(), 192 Check Character, 187 Check Data Type, 186 Conversion, 191 Dec(), 192 Hex(), 192 Hex2str(), 193 Introduction, 185 IsAlNum(), 188 IsAlpha(), 188 IsCntrl(), 188 IsDigit(), 189 IsGraph(), 189 IsList(), 187 IsLower(), 189 IsNULL(), 187 IsNumber(), 186 IsPrint(), 189 IsPunct(), 190 IsSpace(), 190 IsString(), 186 IsUpper(), 190 IsXdigit(), 190 Number(), 191 Str2Hex(), 193 String(), 191 Type(), 187 Database, ModelBase & ControllerBase classes Web Development (CGI Library), 389 DataType Class Stdlib Classes, 317 Date and Time AddDays(), 184 clock(), 182 ClosPerSecond(), 182 Date(), 182 DiffDays(), 184 EpochTime(), 184 Index 1740
  • 56. Ring Documentation, Release 1.5 Introduction, 181 Time(), 182 TimeList(), 183 Date() Date and Time, 182 DateTime Class Stdlib Classes, 312 dayofweek() Stdlib Functions, 295 Debug Class Stdlib Classes, 316 Dec() Data Type, 192 Decimals() Mathematical Functions, 197 Declarative Programming Declarative programming on the top of Object- Oriented, 327 executing code after the end of object access, 327 Introduction, 323 More Beatiful Code, 328 Objects inside lists, 324 Return object by reference, 325 Declarative programming on the top of Object-Oriented Declarative Programming, 327 Declare parameters Functions - First Style, 156 Functions - Second Style, 160 Functions - Third Style, 164 Decrypt() Security and Internet Functions, 247 Deep Copy Variables, 133 Define Declarative Languages Language Design, 22 Define Functions Functions - First Style, 155 Functions - Second Style, 159 Functions - Third Style, 163 Define Natural Statements Language Design, 20 Defining Commands Using the Natural Library, 342 Defining commands using classes Using the Natural Library, 345 Defining Constants Code Generator, 741 Defining Variables and Variables Access Scope Rules, 649 Delete Item From List Lists, 169 Demo Programs Introduction, 218 Language Shell, 219 Main Menu, 219 The Cards Game, 618 Designed for a clear goal Language Design, 17 Desktop and Mobile Development Adding Hyperlink to QLabel, 559 Change Focus, 594 Classes and their Methods to use the default events, 624 Creating Menubar, 539 Creating more than one window, 577 Creating Reports using the WebLib and the GUILib, 629 Creating StatusBar, 543 Creating Toolbar, 542 Dialog Functions, 584 Display Image using QLabel, 563 Display Scaled Image using QLabel, 572 Drawing using QPainter, 574 Dynamic Objects, 598 Inheritance from GUI Classes, 590 KeyPress and Mouse Move Events, 584 Menubar and StyleSheet Example, 564 Methods to use Events with Events Filter, 627 Movable Label Example, 580 Moving Objects using the Mouse, 586 New Classes names - Index Start from 1, 629 Notepad Application, 603 Other Widgets Events, 568 Playing Sound, 578 Printing using QPrinter, 576 QLineEdit Events and QMessageBox, 566 QMessagebox Example, 581 QVideoWidget and QMediaPlayer, 560 Regular Expressions, 595 RingQt Classes and their Qt Documentation, 629 Rotate Text, 592 Simple Client and Server Example, 596 The Cards Game, 618 The Difference between Qt and RingQt, 628 The First GUI Application, 529 Using Layout, 530 Using QCheckBox, 556 Using QComboBox Class, 538 Using QDateEdit, 551 Using QDesktopWidget Class, 591 Using QDial, 552 Using QDockWidget, 544 Using QFrame, 561 Using QInputDialog Class, 582 Using qLCDNumber, 579 Using QProgressBar, 548 Using QProgressBar and Timer, 571 Using QRadioButton and QButtonGroup, 557 Index 1741
  • 57. Ring Documentation, Release 1.5 Using QSlider, 549 Using QSpinBox, 549 Using QTableWidget, 547 Using QTabWidget, 545 Using QTreeView and QFileSystemModel, 536 Using QTreeWidget and QTreeWidgetItem, 537 Using QWebView, 555 Using the QColorDialog Class, 578 Using the QFileDialog Class, 573 Using the QListWidget Class, 533 Using the QTextEdit Class, 532 Using the QTimer Class, 570 Weight History Application, 599 Determine Structure Members Types Code Generator, 741 Dialog Functions Desktop and Mobile Development, 584 DiffDays() Date and Time, 184 Dir() Files, 200 direxists() Stdlib Functions, 297 Disable BreakPoints The Trace Library and the Interactive Debugger, 720 Display Error Message Extension, 728 Display Image RingLibSDL, 421 Display Image using QLabel Desktop and Mobile Development, 563 Display PNG Images RingLibSDL, 422 Display Scaled Image using QLabel Desktop and Mobile Development, 572 Display Transparent Images RingLibSDL, 423 Display Warnings Option What is new in Ring 1.2?, 90 Distributing Applications and Games for Mobile Distributing Ring Application, 682 Distributing Applications for Microsoft Windows Distributing Ring Application, 681 Distributing Ring Application Creating Windows Installer, 681 Distributing Applications and Games for Mobile, 682 Distributing Applications for Microsoft Windows, 681 Introduction, 680 Protecting the Source Code, 681 Using C/C++ Compiler and Linker, 682 Do Again Loop Control Structures - First Style, 141 Documentation How to contribute?, 108 Download Requirements Building RingQt Applications for Mobile, 633 Download Requirements and Update the Android SDK Building Games For Android, 478 Download() Security and Internet Functions, 248 Draw Rectangle RingLibSDL, 422 Drawing Text Game Engine for 2D Games, 433 Drawing using QPainter Desktop and Mobile Development, 574 Drawing using RingOpenGL Using RingOpenGL and RingFreeGLUT for 3D Graphics, 483 Drawing, Animation and Input Graphics and Game Programming, 408 Dynamic Attributes Object Oriented Programming, 256 Dynamic Objects Desktop and Mobile Development, 598 Dynamic Typing Variables, 133 Editors Support How to contribute?, 109 Embedding Ring in Ring Embedding Ring in Ring, 722 Embedding Ring in Ring without sharing the State, 723 Serial Execution of Programs, 723 Embedding Ring in Ring without sharing the State Embedding Ring in Ring, 723 What is new in Ring 1.3?, 83 Embedding Ring Language in C/C++ Programs Introduction, 734 Ring State, 735 Ring State Functions, 735 Ring State Variables, 736 Encourage Organization Language Design, 19 Encrypt() Security and Internet Functions, 246 endswith() Stdlib Functions, 291 Entering Items Form Designer, 647 Enum and Numbers Code Generator, 742 EpochTime() Date and Time, 184 Stdlib Functions, 299 Index 1742
  • 58. Ring Documentation, Release 1.5 Equality of functions Functional Programming, 265 Eval() Eval() and Debugging, 216 Eval() and Debugging Assert(), 218 Eval(), 216 Introduction, 215 Raise(), 217 Try/Carch/Done, 216 evenorodd() Stdlib Functions, 293 Events Code Form Designer, 643 Example Files, 206 Mathematical Functions, 194 Natural Language Programming, 330 Objects Library for RingQt Application, 636 Security and Internet Functions, 247 System Functions, 211 The Type Hints Library, 678 Example - The Trace Library Low Level Functions, 714 Example - Using the Trace Functions Low Level Functions, 710 Example about Sharing Names between Functions and Methods Scope Rules for Functions and Methods, 664 Exceptions Control Structures - Second Style, 147 Control Structures - Third Style, 151 Execute Program Line by Line The Trace Library and the Interactive Debugger, 719 Execute Query and Print Result ODBC Functions, 227 executing code after the end of object access Declarative Programming, 327 Executing code during code generation Code Generator, 742 ExeFileName() Function System Functions, 214 ExeFolder() Function System Functions, 214 Exit Control Structures - First Style, 141 Exit from two loops Control Structures - First Style, 141 Exit/Loop inside sub functions Control Structures - First Style, 142 Extension Check Parameters Count, 727 Check Parameters Type, 728 Display Error Message, 728 Fopen() and Fclose() Implementation, 729 Function Prototype, 729 Function Structure, 727 Get Parameters Values, 728 Introduction, 724 Module Organization, 726 MySQL_Columns() Implementation, 732 Return Value, 728 RING API - list Functions, 730 RING API - String Functions, 732 ring_ext.c, 725 ring_ext.h, 725 Shared Libraries, 733 Sin() Implementation, 729 Extensions in C/C++ How to contribute?, 109 Extract Zip File RingZip, 405 Facebook Login RingLibCurl, 401 factorial() Stdlib Functions, 289 factors() Stdlib Functions, 293 Fclose() Files, 201 Features Introduction, 13 Feof() Files, 204 Ferror() Files, 204 FetchStockData Application Applications developed in little hours, 3 Fexists() Files, 206 Fflush() Files, 202 Fgetc() Files, 205 Fgetpos() Files, 204 Fgets() Files, 205 fibonacci() Stdlib Functions, 290 Fifteen Puzzle Game Applications developed in little hours, 3 Fifteen Puzzle Game 2 Applications developed in little hours, 7 File Class Stdlib Classes, 314 File Hash Index 1743
  • 59. Ring Documentation, Release 1.5 Security and Internet Functions, 247 file2list() Stdlib Functions, 291 Files Clearerr(), 204 Dir(), 200 Example, 206 Fclose(), 201 Feof(), 204 Ferror(), 204 Fexists(), 206 Fflush(), 202 Fgetc(), 205 Fgetpos(), 204 Fgets(), 205 Fopen(), 201 Fputc(), 205 Fputs(), 205 Fread(), 206 Freopen(), 202 Fseek(), 203 Fsetpos(), 204 Ftell(), 203 Fwrite(), 206 Introduction, 198 Numbers and Bytes, 208 Perror(), 204 Read File using Read(), 200 Remove(), 201 Rename(), 201 Rewind(), 203 Tempfile(), 203 Tempname(), 203 Ungetc(), 205 Write file using Write(), 200 filter() Stdlib Functions, 287 Filtering using Expressions Code Generator, 742 Find SubString Strings, 179 Find() and List of Objects Object Oriented Programming, 257 First-Class Functions Functional Programming, 263 First-Class Lists Lists, 173 Flappy Bird 3000 Game Game Engine for 2D Games, 459 Fopen() Files, 201 Fopen() and Fclose() Implementation Extension, 729 For In Loop Control Structures - First Style, 140 Control Structures - Second Style, 147 Control Structures - Third Style, 151 for in to modify lists Control Structures - First Style, 140 For Loop Control Structures - First Style, 139 Control Structures - Second Style, 146 Control Structures - Third Style, 150 Form Designer Entering Items, 647 Events Code, 643 Introduction, 640 Keyboard Shortcuts, 646 Menubar Designer, 646 More Samples and Tests, 648 Running Forms, 643 The Designer Windows, 642 The Properties, 642 Using Layouts, 648 What is new in Ring 1.3?, 84 Window Flags, 647 Fputc() Files, 205 Fputs() Files, 205 Frames Per Second Using RingOpenGL and RingFreeGLUT for 3D Graphics, 516 Fread() Files, 206 Freopen() Files, 202 Frequently Asked Questions Can I connect to dbase/harbour database?, 1716 Can Ring work on Windows XP?, 1718 Conflict between Global Variables and Class At- tributes, 1704 Constructor methods in Ring, 1700 Could you explain the output of the StrCmp() func- tion?, 1707 Getter and Setter Methods, 1702 Goal of including the Main function in Ring, 1698 How can I disable maximize button and resize win- dow?, 1714 How to add Combobox and other elements to the cells of a QTableWidget?, 1721 How to Close a window then displaying another one?, 1713 How to create a Modal Window?, 1713 How to create an array of buttons in GUI applica- tions?, 1712 How to extend RingQt and add more classes?, 1718 How to get the current source file path?, 1705 Index 1744