What is new in Ring 1.8?
In this chapter we will learn about the changes and new features in Ring 1.8 release.
List of changes and new features
Ring 1.8 comes with the next features!
Better Performance
Find in files Application
String2Constant Application
StopWatch Application
More 3D Samples
Compiling on Manjaro Linux
Using This in the class region as Self
Default value for object attributes is NULL
The For Loops uses the local scope
Merge binary characters
FoxRing Library
Better Form Designer
Better Cards Game
Better RingQt
Better Code Generator For Extensions
Better Ring Compiler and VM
Notes to extensions creators
Better Performance
Ring 1.8 is faster than Ring 1.7
The performance gain is between 10% and 100% based on the application.
Check the 3D samples in this release to get an idea about the current performance.
For more information check the Performance Tips chapter.
Find in files Application
Ring 1.8 comes with Find in files application
String2Constant Application
Ring 1.8 comes with String2Constant application
Using this tool we can convert the source code to be based on constants instead of string literals
Then we can store constants in separate source code files that we can translate to different languages
Where we can have special file for each language, like (English.ring, Arabic.ring and so on)
Using this simple tool, the Form Designer is translated to the Arabic language.
For more information check the Multi-language Applications chapter.
StopWatch Application
Ring 1.8 comes with StopWatch application
More 3D Samples
Ring 1.8 comes with more 3D Samples
The next screen shot for the Top-Down view - Many levels of cubes sample
The next screen shot for the Camera Sample
The next screen shot for the Camera and background sample
Developer : Azzeddine Remmal
Compiling on Manjaro Linux
Ring 1.8 is tested on Manjaro Linux too
Tests by : Iip Rifai
Using This in the class region as Self
The class region is the region that comes after the class name and before any method.
Now we can use This in the class region as Self.
Example:
func main
o1 = new program {
test()
}
? o1
class program
this.name = "My Application"
this.version = "1.0"
? name ? version
func test
? "Name = " + name
? "Version = " + version
Output
My Application
1.0
Name = My Application
Version = 1.0
name: My Application
version: 1.0
Note
When we use braces to change the current active object, Using This we can still point to the class.
Tip
The difference between This and Self is that Self point to the current active object that we can change using braces.
Remember that in most cases we don’t need to use This or Self in the class region
We can write
class program name version
Or
class program name="My Application" version="1.0"
Note
We use This or Self in the class region just to avoid conflict with global variables that are defined with the same name.
Default value for object attributes is NULL
Starting from Ring 1.8 the default value for object attributes is NULL
In Ring, the NULL value is just an empty string or a string that contains “NULL”
We can check for NULL values using the isNULL() function
Example:
oProgram = new Program
? oProgram.name
? oProgram.version
? isNULL(oProgram.name)
? isNULL(oProgram.version)
oProgram { name="My Application" version="1.0" }
? isNULL(oProgram.name)
? isNULL(oProgram.version)
? oProgram
class program
name
version
Output:
NULL
NULL
1
1
0
0
name: My Application
version: 1.0
In previous versions of Ring, trying to access the object attribute before assigning a value to it
Will lead to runtime error and you can’t check it using isnull()
The only way was assigning a value or using try/catch/end
We changed this behavior so we can have full control in seamless way.
The For Loops uses the local scope
In Ring 1.8, when the For Loop defines new identifier (variable) it will define it in the local scope.
Example:
x = 10
? x # Print 10
test1()
? x # Print 10
test2()
? x # Print 10
func test1
for x = 1 to 5
next
? x # Print 6
func test2
list = 1:5
for x in list
next
? x # Print NULL (The "For In" loop will kill the reference after the loop)
Output:
10
6
10
NULL
10
Merge binary characters
From Ring 1.0 we can create binary strings and do operations on these strings.
Now in Ring 1.8, we can get individual characters from these strings and merge them together using the ‘+’ operator.
Example:
cStr = "Welcome"
? cstr[1] + cstr[2] + cStr[5]
v = cstr[1] + cstr[2] + cStr[5]
? v
? len(v)
c1 = cStr[1]
? c1
aList = [1,2,3]
cStr = ""
for item in aList
cStr += int2bytes(item)
next
? "All String"
? len(cStr)
? "First Part"
n1 = cStr[1] + cStr[2] + cStr[3] + cStr[4]
? len(n1)
? "Second Part"
n2 = cStr[5] + cStr[6] + cStr[7] + cStr[8]
? len(n2)
? "Third Part"
n3 = cStr[9] + cStr[10] + cStr[11] + cStr[12]
? len(n3)
? "All String"
cString = cStr[1] + cStr[2] + cStr[3] + cStr[4] +
cStr[5] + cStr[6] + cStr[7] + cStr[8] +
cStr[9] + cStr[10] + cStr[11] + cStr[12]
? len(cString)
? ascii(cStr[1])
? len(cStr[2])
Output:
Weo
Weo
3
W
All String
12
First Part
4
Second Part
4
Third Part
4
All String
12
1
1
FoxRing Library
Developer: Jose Rosado
A class with some of the functions I used in FoxPro
Example:
Load "foxring.ring"
mf = new frFunctions
? mf.frAbs(-45)
? mf.frAbs(10-30)
? mf.frAbs(30-10)
? mf.frTransform(" Ring is a good language ",
"@! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
? mf.frAllTrim(" Ring is a good language ", Null)
Output:
45
20
20
RING IS A GOOD LANGUAGE
Ring is a good language
Better Form Designer
Layout Control - Display the control name when loading forms.
Button Control - Display the button images written using relative path.
Table Control - Display the control name when loading forms.
Better behavior in “Bring to front” and “Send to back” operations.
New buttons are added to the toolbar (Duplicate, Bring to front, Send to back, Delete).
Using layouts in (Menubar designer, Window Flags window, Selecting Objects window).
Better behavior for displaying the properties window when changing the selected objects.
New buttons are added to move and resize multiple selection of objects.
Window Properties - Add button to select the layout.
Opening forms and switching between files is faster.
Objects Order window.
Select Objects window.
When we change the control name, the name will be updated in layout objects.
Better Cards Game
The Cards game is updated and we can play with the Computer
Better RingQt
The next classes are added to RingQt
QTabBar
QFile
QFileDevice
QStandardPaths
QDir
QQuickWidget
QQmlError
QScrollBar
RingQt for Android is updated to support modern versions of Qt
Tested using
Qt 5.5.1
Qt 5.9.5
Qt 5.11.0
In RingQt for Android, The Ring Object File (ringo) will be executed directly from resources.
Better Code Generator For Extensions
New Option: StaticMethods
Starting from Ring 1.8 the code generator support the staticmethods option.
So the code generator can know that the class doesn’t need an object to call the methods.
Example:
<class>
name: QStandardPaths
para: void
nonew
staticmethods
</class>
QString displayName(QStandardPaths::StandardLocation type)
QString findExecutable(QString executableName, QStringList paths))
Better Ring Compiler and VM
Better loading for files in relative paths
Code Optimization for eval() function
Better Memory Pool
When embedding Ring in Ring, the error in the hosted environment will not close the host
Example:
? "Start the test!"
pState = ring_state_init()
ring_state_runcode(pState," ? 'Let us try having an error' ? x")
ring_state_delete(pState)
? ""
? "End of test!"
Output:
Start the test!
Let us try having an error
Line 1 Error (R24) : Using uninitialized variable : x
in file Ring_EmbeddedCode
End of test!
The compiler will ignore new lines after keywords that expect tokens after it
Example:
see
"
Hello, World!
"
test()
func
#======================#
Test
#======================#
?
"
Hello from the Test function
"
Output:
Hello, World!
Hello from the Test function
Better code (faster) for the main loop, special loop for eval() function.
Better code (faster) for tracking C pointers to avoid using NULL pointers.
Better code (faster) for getting the self object using braces.
Notes to extensions creators
If you have created new extensions for Ring in the C/C++ languages.
You have to rebuild your extension (Generate the DLL file again using Ring 1.8 header files) before usage with Ring 1.8
Because we changed the internal structure of the VM, but no changes to the code are required. just rebuild.