You are on page 1of 10

CHAPTER

ELEVEN

USING RING NOTEPAD

In this chapter we will learn about using Ring Notepad to write and execute Ring programs quickly
Ring Notepad is just a simple application developed using the Ring language.

11.1 Ring Notepad - Main Window

When we run the Ring Notepad we get three dockable windows


Project Files Window : where we can select and open any ring file (*.ring) quickly.
Source Code Window : Where we write the source code.
Web Browser Window : Where we read the documentation or quickly open any website.

11.2 Creating and running your first Console Application

At first we will type the source code

50
Ring Documentation, Release 1.2

See "Hello, World!"

As in the next image

Then we will click on the Save button from the toolbar (or press CTRL+S)

Determine the source code file name and location.


For example type : hello
This will create a new source code file called : hello.ring

11.2. Creating and running your first Console Application 51


Ring Documentation, Release 1.2

To run the program click on Debug (Run then wait!) button from the toolbar

The next screen shot present the application during the runtime
Press Enter to continue and return to the Ring Notepad.

11.2. Creating and running your first Console Application 52


Ring Documentation, Release 1.2

11.3 Creating and running your first GUI/Mobile Application

To learn how to create GUI applications using Ring check the Desktop and Mobile development using RingQt
chapter.
Source Code:
Load "guilib.ring"

New qApp {
new qWidget() {
resize(400,400)
setWindowTitle("Hello, World!")
show()
}
exec()
}

In Ring notepad we have a special button to run GUI applications without displaying the console window.

11.3. Creating and running your first GUI/Mobile Application 53


Ring Documentation, Release 1.2

The next screen shot present the application during the runtime

11.4 Creating and running your first Web Application

To learn how support Ring in your web server and how to create web applications using Ring check the Web Devel-
opment (CGI Library) chapter.

Note: You need to support the Ring language in your web server to be able to run the next example.

Source Code:

11.4. Creating and running your first Web Application 54


Ring Documentation, Release 1.2

#!b:\ring\bin\ring.exe -cgi

load "weblib.ring"

Import System.Web

new page {

text("Hello, World!")

We can run the application in any web browser or in the browser that are embedded in Ring Notepad.

11.5 Creating and running your first Desktop/Mobile Game

To learn about creating 2D Games using Ring check the Demo Project - Game Engine for 2D Games chapter.
Source Code:
Load "gameengine.ring"

func main

oGame = New Game


{
title = "My First Game"
sprite
{
type = GE_TYPE_PLAYER
x=400 y=400 width=100 height=100
file = "images/player.png"
transparent = true
Animate=false

11.5. Creating and running your first Desktop/Mobile Game 55


Ring Documentation, Release 1.2

Move=true
Scaled=true
}
}

We can run the application as any GUI application.

11.5. Creating and running your first Desktop/Mobile Game 56


CHAPTER

TWELVE

USING OTHER CODE EDITORS

In the Ring/Editor folder you will find extensions for the next editors
Notepad++
Geany
Atom
Sublime Text 2
Visual Studio IDE

12.1 Using Notepad++

Folder : ring/editor/notepad_plus_plus
Open Notepad++
Open the Language menu
Select Define your language...
Click Import...
select Ring.xml
Select OK on the Import successful dialog and close the User Defined Language dialog/panel
You may need to restart notepad++

57
Ring Documentation, Release 1.2

12.2 Using Geany

Folder : ring/editor/geany
Run Geany editor
Click on Tools -> configuration files -> filetypes_extensions.conf menu
Add this line Ring=*.ring; without quotes after [Extensions]
In unbuntu copy file filetypes.Ring.conf to folder /home/USERNAME/filetypes.Ring.conf
You can run your files by pressing F5 button

12.2. Using Geany 58


Ring Documentation, Release 1.2

12.3 Using Atom

Folder : ring/editor/atom
Just Copy the folder atom-language-ring to the next path C:Users{UserName}.atomPackages

12.3. Using Atom 59

You might also like