What is new in Ring 1.6?

In this chapter we will learn about the changes and new features in Ring 1.6 release.

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

Employee Application

The Employee application is added to ring/applications

Developer: Ahmed Hassouna

Employee Sample

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!

Better Ring For Android

Ring For Android (using RingQt) is updated to use the Ring Object File ( *.ringo ) instead of using many source code files ( *.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 files) it will use only one *.ringo file.

Better Ring for Android

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
Form Designer - Android

New Tool: Folder2qrc

When we have large RingQt project that contains a lot of images and files, We need to add these files to the resource file ( *.qrc ) when distributing applications for Mobile devices.

Instead of adding these files 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 file while we are in the application folder, and Folder2qrc will check all of the files in the current folder and sub folders, Then add them to the resource file after the mainfile.ringo (In our example this will be formdesigner.ringo)

The output file will be : project.qrc

You can open it and remove the files that you don’t need in the resources!

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 find the Visual C/C++ compiler based on your Visual Studio version.

RingConsoleColors Extension

Using the RingConsoleColors extension we can easily change the colors used in our console applications

RingConsoleColors

For more information check the RingConsoleColors chapter in the documentation.

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.

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 file 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

Ring Notepad - Run Web Application - shot 1

For Windows users, Ring 1.6 comes with Apache Web server!

We can run any web application from any folder directly without doing any configuration.

Ring Notepad - Run Web Application - shot 2
  1. Tools - Operating System - Terminal (Command Prompt) & Files Manager (Explorer).

Ring Notepad - Tools - Terminal - shot 1

So we can quickly open the Command Prompt or the Explorer at the application folder.

Ring Notepad - Tools - Terminal - shot 2
  1. Support *.sh & *.bat extensions.

  2. New Menu: Distribute

Ring Notepad - Distribute

Better RingQt

RingQt comes with the next updates

  1. QAllEvents - getkeytext() Method

  2. QSQLQuery - exec_2() Method

  3. QDockWidget Events

  4. AppFile() Function

  5. IsMobile() Function

  6. QRegion Class

  7. QCoreApplication class

Better StdLib

StdLib comes with the next updates

  1. Factors() function is updated (Return the output instead of printing it)

  2. Palindrome() function is updated (Return the output instead of printing it)

  3. Using stdlibcore.ring we can use the StdLib functions (Without Classes)

    Also this is useful when developing standalone console applications

    Because using stdlib.ring (functions & classes) will load libraries like RingLibCurl, RingOpenSSL, etc.

  4. New Functions

  • SystemSilent(cCommand) Function : Execute system commands without displaying the output.

  • OSCreateOpenFolder(cFolder) : Create folder then change the current folder to this new folder

  • OSCopyFolder(cParentFolder,cFolderNameToCopy) : Copy folder to the current directory

  • OSDeleteFolder(cFolder) : Delete Folder

  • OSCopyFile(cFileName) : Copy File to the current directory

  • OSDeleteFile(cFileName) : Delete File

  • OSRenameFile(cOldFileName,cNewFileName) : Rename file

Better RingVM

RingVM comes with the next updates

  1. Support using many getter methods in Expressions

  2. Support using this & self in setter/getter/normal methods without calling setter/getter methods.

  3. TempName() function is updated (Better Code)

  4. ExeFileName() function is updated (Better Code)

  5. Private Attributes - Support re-usage in the class region (After the keyword private)

  6. Ring API : ring_scanner_runobjstring()

  7. ring_state_setvar() function

Better RingREPL

RingREPL comes with the next updates

  1. RingREPL will get command line parameters to determine the style.

  2. Setting RingREPL Style based on Ring Notepad Style.

Using Tab instead of char(9)

The variable Tab is defined to be used instead of char(9)

Example (1):

see :one + nl + tab + :two + nl + tab + tab + :three

Output:

one
        two
                three

You can change the variable to another value

Example (2):

tab = "  "
see :one + nl + tab + :two + nl + tab + tab + :three

Output:

one
  two
    three

Using CR as Carriage return

The next example count from 1 to 10 in the same line during 10 seconds

load "stdlibcore.ring"
for x = 1 to 10 see x sleep(1) see cr next

Using the ! operator as not

We have = and != in the Ring language

But for the logical operators we have and, or & not

Now we can use the ! operator as not

Example:

if ! false
        see "True!" + nl
ok

Output

True!

Using && and || operators

In Ring we have the next keywords for the logical operations

  • and

  • or

  • not

Now we have also the next operators

  • &&

  • ||

  • !

Example:

if one() and two()
        see "Test1 - Fail" + nl
else
        see "Test1 - Pass" + nl
ok

if two() or one()
        see "Test2 - Pass" + nl
else
        see "Test2 - Fail" + nl
ok

if one() && two()
        see "Test3 - Fail" + nl
else
        see "Test3 - Pass" + nl
ok

if two() || one()
        see "Test4 - Pass" + nl
else
        see "Test4 - Fail" + nl
ok

func one return True

func two return False

Output:

Test1 - Pass
Test2 - Pass
Test3 - Pass
Test4 - Pass

Using ? to print expression then new line

It’s common to print new line after printing an expression, We can use the ? operator to do that!

Example:

? "Hello, World!"
for x = 1 to 10
        ? x
next

Output:

Hello, World!
1
2
3
4
5
6
7
8
9
10