WhatsApp 9892124323 āCall Girls In Kalyan ( Mumbai ) secure service
Ā
The Ring programming language version 1.7 book - Part 8 of 196
1. Ring Documentation, Release 1.7
12. QQuaternion
13. QMatrix4x4
14. QOpenGLPaintDevice
15. QPaintDevice
16. QOpenGLTimerQuery
17. QOpenGLDebugLogger
18. QOpenGLFramebufferObject
19. QOpenGLVertexArrayObject
20. QOpenGLBuffer
21. QOpenGLShaderProgram
22. QOpenGLShader
23. QOpenGLTexture
4.8 Better Ring2EXE
Ring2EXE is updated to works as expected when we donāt have a C/C++ compiler
Where we can distribute applications and get (exe ļ¬le and ringo ļ¬le) in this case.
4.9 Better RingZip
The library is updated to support extracting ļ¬les contains sub folders!
4.10 Better Documentation
1. RingQt Classes Chapter - The classes are sorted.
4.11 Better Ring VM
1. Better Error Message
2. List2Str() function support lists contains numbers
3. Correct support for numbers contains _ as separator
4. Creating lists without variables (statement ā> Expression ā> List)
5. IsNULL() - Not case sensitive - treat Null and null like NULL
6. Support adding the Self object to an attribute in this object
7. Using ā:ā operator then keyword will create lower case literal
8. Printing objects - respect decimals() function
9. When literal is not closed - determine the start of the literal
4.8. Better Ring2EXE 42
2. Ring Documentation, Release 1.7
10. Better message when printing objects contains lists
11. VarPtr() - Support getting a pointer to variables in the local scope
12. replace performance instructions with normal instructions when creating new threads
4.12 RingLibuv Extension
Ring 1.7 comes with the RingLibuv extension
Libuv is a multi-platform support library with a focus on asynchronous I/O.
Example (Events Loop):
load "libuv.ring"
counter = 0
idler = NULL
func main
idler = new_uv_idle_t()
uv_idle_init(uv_default_loop(), idler)
uv_idle_start(idler, "wait()")
? "Idling..."
uv_run(uv_default_loop(), UV_RUN_DEFAULT);
uv_loop_close(uv_default_loop());
destroy_uv_idle_t(idler)
func wait
counter++
if counter >= 100000
uv_idle_stop(idler)
ok
Output:
Idling...
Example (Server):
load "libuv.ring"
load "objectslib.ring"
? "Testing RingLibuv - Server Side - Using Classes"
open_object(:MyServer)
class MyServer from ObjectControllerParent
DEFAULT_PORT = 13370
DEFAULT_BACKLOG = 1024
addr = new_sockaddr_in()
server = NULL
client = NULL
myloop = NULL
func start
myloop = uv_default_loop()
4.12. RingLibuv Extension 43
3. Ring Documentation, Release 1.7
server = new_uv_tcp_t()
uv_tcp_init(myloop, server)
uv_ip4_addr("127.0.0.1", DEFAULT_PORT, addr)
uv_tcp_bind(server, addr, 0)
r = uv_listen(server, DEFAULT_BACKLOG, Method(:newconnection) )
if r
? "Listen error " + uv_strerror(r)
return 1
ok
uv_run(myloop, UV_RUN_DEFAULT)
destroy_uv_tcp_t(server)
destroy_uv_sockaddr_in(addr)
func newconnection
? "New Connection"
aPara = uv_Eventpara(server,:connect)
nStatus = aPara[2]
if nStatus < 0
? "New connection error : " + nStatus
return
ok
client = new_uv_tcp_t()
uv_tcp_init(myloop, client)
if uv_accept(server, client) = 0
uv_read_start(client, uv_myalloccallback(),
Method(:echo_read))
ok
func echo_read
aPara = uv_Eventpara(client,:read)
nRead = aPara[2]
buf = aPara[3]
if nRead > 0
req = new_uv_write_t()
wrbuf = uv_buf_init(get_uv_buf_t_base(buf), nread)
uv_write(req, client, wrbuf, 1, Method(:echo_write))
? uv_buf2str(wrbuf)
message = "message from the server to the client"
buf = new_uv_buf_t()
set_uv_buf_t_len(buf,len(message))
set_uv_buf_t_base(buf,varptr("message","char *"))
uv_write(req, client, buf, 1, Method(:echo_write))
ok
func echo_write
aPara = uv_Eventpara(client,:read)
req = aPara[1]
Output:
When we run the client, We will see the message āNew Connectionā
Then the message āhello from the clientā
Testing RingLibuv - Server Side - Using Classes
New Connection
hello from the client
Example (Using Threads):
4.12. RingLibuv Extension 44
4. Ring Documentation, Release 1.7
load "libuv.ring"
load "objectslib.ring"
? "Testing RingLibuv - Threads - Using Classes"
open_object(:MyThreads)
class MyThreads from ObjectControllerParent
func Start
one_id = new_uv_thread_t()
two_id = new_uv_thread_t()
uv_thread_create(one_id, Method(:One))
uv_thread_create(two_id, Method(:Two))
uv_thread_join(one_id)
uv_thread_join(two_id)
destroy_uv_thread_t(one_id)
destroy_uv_thread_t(two_id)
func one
? "Message from the First Thread!"
func Two
? "Message from the Second Thread!"
Output:
Testing RingLibuv - Threads - Using Classes
Message from the First Thread!
Message from the Second Thread!
For more information about this extension (RingLibuv) check the chapter: Using RingLibuv
4.12. RingLibuv Extension 45
5. CHAPTER
FIVE
WHAT IS NEW IN RING 1.6?
In this chapter we will learn about the changes and new features in Ring 1.6 release.
5.1 List of changes and new features
Ring 1.6 comes with many new features!
ā¢ Employee Application
ā¢ New Tool: Ring2EXE
ā¢ Better Ring For Android
ā¢ New Tool : Folder2qrc
ā¢ Better Scripts for building Ring
ā¢ RingConsoleColors Extension
ā¢ RingMurmurHash Extension
ā¢ Better Ring Notepad
ā¢ Better RingQt
ā¢ Better StdLib
ā¢ Better RingVM
ā¢ Better RingREPL
ā¢ Using Tab instead of char(9)
ā¢ Using CR as Carriage return
ā¢ Using the ! operator as not
ā¢ Using && and || operators
ā¢ Using ? to print expression then new line
5.2 Employee Application
The Employee application is added to ring/applications
Developer: Ahmed Hassouna
46
6. Ring Documentation, Release 1.7
5.3 New Tool: Ring2EXE
In Ring 1.6 we have a nice tool called Ring2EXE (Written in Ring itself)
Using Ring2EXE we can distribute applications quickly for Windows, Linux, macOS and Mobile devices
Read the chapter āDistributing Ring Applications using Ring2EXEā for more information!
5.4 Better Ring For Android
Ring For Android (using RingQt) is updated to use the Ring Object File ( *.ringo ) instead of using many source code
ļ¬les ( *.ring )
The next screen shot is an example of building the cards game for Android
We are using cards.ringo instead of cards.ring
If you have large project (many *.ring ļ¬les) it will use only one *.ringo ļ¬le.
5.3. New Tool: Ring2EXE 47
7. Ring Documentation, Release 1.7
To prepare Qt project to distribute RingQt application for Mobile use Ring2EXE
Example
ring2exe cards.ring -dist -mobileqt
Example (2)
ring2exe formdesigner.ring -dist -mobileqt
5.4. Better Ring For Android 48
8. Ring Documentation, Release 1.7
5.5 New Tool: Folder2qrc
When we have large RingQt project that contains a lot of images and ļ¬les, We need to add these ļ¬les to the resource
ļ¬le ( *.qrc ) when distributing applications for Mobile devices.
Instead of adding these ļ¬les one by one, Ring 1.6 comes with a simple tool that save our time, Itās called Folder2qrc.
Example:
folder2qrc formdesigner.ring
We determine the main source ļ¬le while we are in the application folder, and Folder2qrc will check all of the ļ¬les in
the current folder and sub folders, Then add them to the resource ļ¬le after the mainļ¬le.ringo (In our example this will
be formdesigner.ringo)
The output ļ¬le will be : project.qrc
You can open it and remove the ļ¬les that you donāt need in the resources!
5.6 Better Scripts for building Ring
Ring 1.6 comes with better scripts for building Ring from source code.
The updates are tested on 32bit and 64bit systems on Windows, Linux (Ubuntu,Fedora) and macOS.
The scripts for Windows are updated to ļ¬nd the Visual C/C++ compiler based on your Visual Studio version.
5.7 RingConsoleColors Extension
Using the RingConsoleColors extension we can easily change the colors used in our console applications
For more information check the RingConsoleColors chapter in the documentation.
5.5. New Tool: Folder2qrc 49
9. Ring Documentation, Release 1.7
5.8 RingMurmurHash Extension
Ring 1.6 comes with the RingMurmurHash extension!
Developer: Hassan Ahmed
Example:
load "murmurhashlib.ring"
key = "Ring Language"
see murmurhash3_x86_32(key, 0, 0) + nl // Output: 1894444853
see murmurhash3_x86_32(key, 0, 1) + nl // Output: 70eaef35
For more information check the RingMurmurHash chapter in the documentation.
5.9 Better Ring Notepad
Ring Notepad comes with the next updates
1. Automatic setting for the Main File when we Run the application (using the Main ļ¬le buttons).
2. Main File - Automatic save before running.
3. When we run GUI application - donāt change the focus to the text box used for the input in the Output Window.
4. A button and option to run web applications
For Windows users, Ring 1.6 comes with Apache Web server!
We can run any web application from any folder directly without doing any conļ¬guration.
5.8. RingMurmurHash Extension 50
10. Ring Documentation, Release 1.7
5. Tools - Operating System - Terminal (Command Prompt) & Files Manager (Explorer).
So we can quickly open the Command Prompt or the Explorer at the application folder.
5.9. Better Ring Notepad 51