2 single: What is new in Ring 1.2?; Introduction
4 ========================
5 What is new in Ring 1.2?
6 ========================
8 In this chapter we will learn about the changes and new features in Ring 1.2 release.
11 pair: What is new in Ring 1.2?; List of changes and new features
13 List of changes and new features
14 ================================
16 Ring 1.2 comes with many new features
22 * Objects Library for RingQt
25 * Using NULL instead of NULLPointer()
26 * Display Warnings Option
30 pair: What is new in Ring 1.2?; New Functions
35 * PtrCmp() Function is a new function that compare between C pointers like the GUI objects.
36 * PrevFileName() Function is added to return the previous active source file name.
37 * RingVM_CFunctionsList() Function is added to return a list of functions written in C.
38 * RingVM_FunctionsList() Function is added to return a list of functions written in Ring.
39 * RingVM_ClassesList() Function is added to return a list of Classes.
40 * RingVM_PackagesList() Function is added to return a list of Packages.
41 * RingVM_MemoryList() Function is added to return a list of Memory Scopes and Variables.
42 * RingVM_CallList() Function is added to return a list of the functions call list.
43 * RingVM_FilesList() Function is added to return a list of the Ring Files.
49 fp = fopen("ptrcmp.ring","r")
51 fp3 = fopen("ptrcmp.ring","r")
53 see ptrcmp(fp,fp2) + nl
54 see ptrcmp(fp,fp3) + nl
66 Also we can compare between them using the '=' operator
72 fp = fopen("ptrcmp2.ring","r")
73 fp2 = fopen("ptrcmp2.ring","r")
91 The next function in stdlib.ring uses the PrevFileName() to know if the file of the
92 caller function is the main source file of the program or not.
97 if PrevFileName() = sysargv[2]
103 pair: What is new in Ring 1.2?; Better Functions
108 The find() function is updated to support searching in lists using C pointers like GUI
111 The type() function is updated to display the C pointers types (like the GUI Object Class
115 pair: What is new in Ring 1.2?; Better Ring Notepad
120 The Ring Notepad will save the current line number of opened files to be restored when
121 we switch between files.
123 Also Ring Notepad will ask the user to save the file if the file content is changed when
124 the user switch between files.
127 pair: What is new in Ring 1.2?; Better RingQt
132 RingQt classes are updated to include methods to get events (The code that will be executed
133 when an event is fired). This is necessary to enable/disable events for some time or to
134 get the events information.
136 For example the next code disable an event then call a method then enable the event again.
140 cEvent = oView.oListResult.getCurrentItemChangedEvent()
141 oView.oListResult.setCurrentItemChangedEvent("")
142 FindValueAction() # Call Method while an event is disabled
143 oView.oListResult.setCurrentItemChangedEvent(cEvent)
145 Also the QAllEvents class is updated where we can set the output from the event function
146 to be true or false using a new method added to the class called setEventOutput.
153 win = new qWidget() {
154 setwindowtitle("Hello World")
155 setGeometry(100,100,370,250)
156 lineedit1 = new qlineedit(win) {
157 setGeometry(10,100,350,30)
158 setinputmask("9999;_")
159 oFilter = new qallevents(lineedit1)
160 oFilter.setfocusoutEvent("pMove()")
161 installeventfilter(oFilter)
163 lineedit2 = new qlineedit(win) {
164 setGeometry(10,150,350,30)
172 win.setWindowTitle("xxxx")
173 oFilter.setEventOutput(False)
176 pair: What is new in Ring 1.2?; Objects Library for RingQt
178 Objects Library for RingQt
179 ==========================
181 Ring 1.2 comes with the Objects library for RingQt applications. Instead of using global
182 variables for windows objects and connecting events to objects using the object name, the
183 Objects Library will manage the GUI objects and will provide a more natural API to quickly
184 create one or many windows from the same class and the library provide a way to quickly set methods
185 to be executed when an event is fired. Also the library provide a natural interface to
186 quickly use the parent or the caller windows from the child or sub windows.
188 The Objects Library is designed to be used with the MVC Design Pattern.
190 The Objects Library is merged in RingQt so you can use it directly when you use RingQt
199 open_window( :MainWindowController )
203 class MainWindowController from WindowsControllerParent
204 oView = new MainWindowView
206 Open_window( :SubWindowController )
207 Last_Window().SetParentObject(self)
209 class MainWindowView from WindowsViewParent
210 win = new qWidget() {
211 SetWindowTitle("Main Window")
212 btnSub = new qPushButton(win) {
213 setText("Sub Window")
214 setClickEvent( Method( :SubWindowAction ) )
219 class SubWindowController from WindowsControllerParent
220 oView = new SubWindowView
221 func SetMainWindowTitleAction
222 Parent().oView.win.SetWindowTitle("Message from the Sub Window")
223 oView.win.SetWindowTitle("Click Event Done!")
225 class SubWindowView from WindowsViewParent
226 win = new qWidget() {
227 SetWindowTitle("Sub Window")
228 btnMsg = new qPushButton(win) {
229 setText("Set Main Window Title")
230 setClickEvent( Method( :SetMainWindowTitleAction ) )
232 btnClose = new qPushButton(win) {
235 setClickEvent( Method( :CloseAction ) )
241 pair: What is new in Ring 1.2?; RingLibCurl
246 The LibCurl library is used starting from Ring 1.0 for the Download() and SendEmail()
247 functions implementation. In Ring 1.2 more functions are added to provide a powerful
248 library (RingLibCurl) around LibCurl.
256 curl = curl_easy_init()
258 cPostThis = "page=4&Number1=4&Number2=5"
259 curl_easy_setopt(curl, CURLOPT_URL, "http://localhost/ringapp/index.ring?page=3")
260 curl_easy_setopt(curl, CURLOPT_POSTFIELDS, cPostThis)
262 curl_easy_perform(curl)
264 curl_easy_cleanup(curl)
268 pair: What is new in Ring 1.2?; Better Call Command
273 The Call command is updated to support calling functions from object attributes also (not
276 For example the next code from the Stars Fighter Game
280 cFunc = oself.keypress
281 call cFunc(oGame,oSelf,Key_Space)
283 Can be written in one line
287 call oself.keypress(oGame,oSelf,Key_Space)
291 pair: What is new in Ring 1.2?; Using NULL instead of NULLPointer()
293 Using NULL instead of NULLPointer()
294 ===================================
296 We can pass NULL to functions instead of using NULLPointer()
298 For example the next code from RingLibSDL
302 SDL_RenderCopy(SDL_ren,tex,NULLPointer(),rect)
304 Can be written as in the next line
308 SDL_RenderCopy(SDL_ren,tex,NULL,rect)
311 pair: What is new in Ring 1.2?; Display Warnings Option
313 Display Warnings Option
314 =======================
316 In Ring 1.2 the Ring compiler is updated to include the Display Warnings option (-w)
325 compiling the program using the Display Warnings option will display the file duplication
326 warning, While without that option the error will pass silent.
328 This is a warning (not an error) because in large projects you may use the same file
329 more than one time. For example it's common to start each file with the next code. where
330 the function IsMainSourceFile() is part from the stdlib.ring
335 if IsMainSourceFile()
340 pair: What is new in Ring 1.2?; Better Quality
345 Ring 1.2 is more stable, We discovered and fixed more bugs during Ring usage everyday
346 in practical projects. Some functions are optimized to be faster like the SubStr() function.
347 Also the documentation is more better.