Sie sind auf Seite 1von 10

Ring Documentation, Release 1.5.

2. https://github.com/ring-lang/ring/blob/master/applications/formdesigner/tests/indexstart/indexstartController.ring

6.3 Better Ring Notepad

1. Using QPlainTextEdit instead of QTextEdit


2. Displaying the line number for each line in the source code file.
Screen Shot:

3. Auto-Complete for Ring functions names, classes and words in the opened file.

6.3. Better Ring Notepad 95


Ring Documentation, Release 1.5.3

4. Functions and Methods List

6.3. Better Ring Notepad 96


Ring Documentation, Release 1.5.3

5. Output Window

6. Classes List

6.3. Better Ring Notepad 97


Ring Documentation, Release 1.5.3

7. Change the Current Style

6.4 Ring mode for Emacs Editor

Ring 1.3 comes with Ring mode for Emacs Editor


Screen Shot:

6.4. Ring mode for Emacs Editor 98


Ring Documentation, Release 1.5.3

6.5 Better StdLib

The StdLib is updated to include the next functions


• SplitMany()
• JustFilePath()
• JustFileName()

6.6 Better Loop|Exit Command

The Loop|Exit command is updated to accept Expressions after the command (not only numbers).
The syntax:
Loop|Exit [Number]

Changed to
Loop|Exit [Expression]

Example
XLoop = 2 # The outer loop
YLoop = 1 # The first inner loop
for x = 1 to 10
for y = 1 to 10
see "x=" + x + " y=" + y + nl
if x = 3 and y = 5
exit XLoop
ok

6.5. Better StdLib 99


Ring Documentation, Release 1.5.3

next
next

6.7 New Functions

• PackageName() function
• Swap() function
Example:
aList = [:one,:two,:four,:three]
see aList
see copy("*",50) + nl
swap(aList,3,4)
see aList

Output
one
two
four
three
**************************************************
one
two
three
four

6.8 Return Self by Reference

In this release, using Return Self in class methods will return the object by reference.
Example:
mylist = [new mytest() {
see self
x = 20
see self
}]

see mylist

class mytest
x = 15
func init
return self # Return by reference

Output
x: 15.000000
x: 20.000000
x: 20.000000

6.7. New Functions 100


Ring Documentation, Release 1.5.3

6.9 Using ‘<’ and ‘:’ operators as ‘from’ keyword

In this release of the Ring language we can use the ‘<’ and ‘:’ operators as the ‘from’ keyword
Syntax (1):
class Cat from Animal

Syntax (2):
class Cat < Animal

Syntax (3):
class Cat : Animal

6.10 Embedding Ring in Ring without sharing the State

From Ring 1.0 we already have functions for embedding Ring in the C language. Also we can execute Ring code
inside Ring programs using the eval() function. In this release we provide functions for embedding Ring in Ring
programs without sharing the state.
Advantages:
1. Quick integration for Ring programs and applications together without conflicts.
2. Execute and run Ring code in safe environments that we can trace.
Example:
pState = ring_state_init()
ring_state_runcode(pState,"See 'Hello, World!'+nl")
ring_state_runcode(pState,"x = 10")

pState2 = ring_state_init()
ring_state_runcode(pState2,"See 'Hello, World!'+nl")
ring_state_runcode(pState2,"x = 20")

ring_state_runcode(pState,"see x +nl")
ring_state_runcode(pState2,"see x +nl")

v1 = ring_state_findvar(pState,"x")
v2 = ring_state_findvar(pState2,"x")

see v1[3] + nl
see V2[3] + nl

ring_state_delete(pState)
ring_state_delete(pState2)

Output:
Hello, World!
Hello, World!
10
20
10
20

6.9. Using ‘<’ and ‘:’ operators as ‘from’ keyword 101


Ring Documentation, Release 1.5.3

6.11 RingZip Library

Ring 1.3 comes with the RingZip library for creating, modifying and extracting *.zip files.
Example (1): Create myfile.zip contains 4 files
load "ziplib.ring"
oZip = zip_openfile("myfile.zip",'w')
zip_addfile(oZip,"test.c")
zip_addfile(oZip,"zip.c")
zip_addfile(oZip,"zip.h")
zip_addfile(oZip,"miniz.h")
zip_close(oZip)

Example (2): Extract myfile.zip to myfolder folder.


load "ziplib.ring"
zip_extract_allfiles("myfile.zip","myfolder")

Example (3): Print file names in the myfile.zip


load "ziplib.ring"
oZip = zip_openfile("myfile.zip",'r')
for x=1 to zip_filescount(oZip)
see zip_getfilenamebyindex(oZip,x) + nl
next
zip_close(oZip)

Example (4) : Using Classes instead of Functions


load "ziplib.ring"

new Zip {
SetFileName("myfile.zip")
Open("w")
AddFile("test.c")
AddFile("zip.c")
AddFile("zip.h")
AddFile("miniz.h")
Close()
}

6.12 Form Designer

Ring 1.3 comes with the Form Designer to quickly design your GUI application windows/forms and generate the Ring
source code.
It’s written in Ring (Around 8000 Lines of code) using Object-Oriented Programming and Meta-Programming.
We can run the From Designer from Ring Notepad

6.11. RingZip Library 102


Ring Documentation, Release 1.5.3

Also we can run the Form Designer in another window.

6.12. Form Designer 103


CHAPTER

SEVEN

WHAT IS NEW IN RING 1.2?

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

7.1 List of changes and new features

Ring 1.2 comes with many new features


• New Functions
• Better Functions
• Better Ring Notepad
• Better RingQt
• Objects Library for RingQt
• RingLibCurl
• Better Call Command
• Using NULL instead of NULLPointer()
• Display Warnings Option
• Better Quality

7.2 New Functions

• PtrCmp() Function is a new function that compare between C pointers like the GUI objects.
• PrevFileName() Function is added to return the previous active source file name.
• RingVM_CFunctionsList() Function is added to return a list of functions written in C.
• RingVM_FunctionsList() Function is added to return a list of functions written in Ring.
• RingVM_ClassesList() Function is added to return a list of Classes.
• RingVM_PackagesList() Function is added to return a list of Packages.
• RingVM_MemoryList() Function is added to return a list of Memory Scopes and Variables.
• RingVM_CallList() Function is added to return a list of the functions call list.
• RingVM_FilesList() Function is added to return a list of the Ring Files.
Example:

104

Das könnte Ihnen auch gefallen