OSDN Git Service

【更新内容】
[ring-lang-081/ring.git] / docs / en / source / whatisnew8.txt
1 .. index:: 
2         single: What is new in Ring 1.8?; Introduction
3
4 ========================
5 What is new in Ring 1.8?
6 ========================
7
8 In this chapter we will learn about the changes and new features in Ring 1.8 release.
9
10 .. index:: 
11         pair: What is new in Ring 1.8?; List of changes and new features
12
13 List of changes and new features
14 ================================
15
16 Ring 1.8 comes with the next features!
17
18 * Better Performance
19 * Find in files Application
20 * String2Constant Application
21 * StopWatch Application
22 * More 3D Samples
23 * Compiling on Manjaro Linux
24 * Using This in the class region as Self
25 * Default value for object attributes is NULL
26 * The For Loops uses the local scope
27 * Merge binary characters
28 * FoxRing Library
29 * Better Form Designer
30 * Better Cards Game
31 * Better RingQt
32 * Better Code Generator For Extensions
33 * Better Ring Compiler and VM
34 * Notes to extensions creators
35
36 .. index:: 
37         pair: What is new in Ring 1.8?; Better Performance 
38
39 Better Performance
40 ==================
41
42 Ring 1.8 is faster than Ring 1.7 
43
44 The performance gain is between 10% and 100% based on the application.
45
46 Check the 3D samples in this release to get an idea about the current performance.
47
48 For more information check the Performance Tips chapter.
49
50 .. index:: 
51         pair: What is new in Ring 1.8?; Find in files Application
52
53 Find in files Application
54 =========================
55
56 Ring 1.8 comes with Find in files application
57
58 .. image:: findinfiles.png
59         :alt: Find in files
60
61
62 .. index:: 
63         pair: What is new in Ring 1.8?; String2Constant Application
64
65 String2Constant Application
66 ===========================
67
68 Ring 1.8 comes with String2Constant application
69
70 Using this tool we can convert the source code to be based on constants instead of string literals
71
72 Then we can store constants in separate source code files that we can translate to different languages
73
74 Where we can have special file for each language, like (English.ring, Arabic.ring and so on)
75
76 Using this simple tool, the Form Designer is translated to the Arabic language.
77
78 For more information check the Multi-language Applications chapter.
79
80 .. image:: string2constant.png
81         :alt: String2Constant 
82
83
84 .. index:: 
85         pair: What is new in Ring 1.8?; StopWatch Application
86
87 StopWatch Application
88 =====================
89
90 Ring 1.8 comes with StopWatch application
91
92 .. image:: stopwatch.png
93         :alt: StopWatch
94
95 .. index:: 
96         pair: What is new in Ring 1.8?; More 3D Samples
97
98 More 3D Samples
99 ===============
100
101 Ring 1.8 comes with more 3D Samples
102
103 The next screen shot for the Top-Down view - Many levels of cubes sample
104
105 .. image:: more3dsamples.jpg
106         :alt: 3D samples
107
108 The next screen shot for the Camera Sample
109
110 .. image:: more3dsamples2.jpg
111         :alt: 3D samples
112
113 The next screen shot for the Camera and background sample
114
115 Developer : Azzeddine Remmal
116
117 .. image:: cameraandbackground.png
118         :alt: Camera and background
119
120
121 .. index:: 
122         pair: What is new in Ring 1.8?; Compiling on Manjaro Linux
123
124 Compiling on Manjaro Linux
125 ==========================
126
127 Ring 1.8 is tested on Manjaro Linux too
128
129 Tests by : Iip Rifai
130
131 .. image:: ringonmanjarolinux.png
132         :alt: Ring on Manjaro Linux
133
134
135 .. index:: 
136         pair: What is new in Ring 1.8?; Using This in the class region as Self
137
138 Using This in the class region as Self
139 ======================================
140
141 The class region is the region that comes after the class name and before any method.
142
143 Now we can use This in the class region as Self.
144
145 Example:
146
147 .. code-block:: ring
148
149         func main
150
151                 o1 = new program {
152                         test()
153                 }
154
155                 ? o1
156
157         class program 
158
159                 this.name = "My Application"
160                 this.version = "1.0"
161                 ? name ? version        
162
163                 func test
164                         ? "Name    = " + name 
165                         ? "Version = " + version
166
167 Output
168
169 .. code-block:: none
170
171         My Application
172         1.0
173         Name    = My Application
174         Version = 1.0
175         name: My Application
176         version: 1.0
177
178 .. note:: When we use braces to change the current active object, Using This we can still point to the class.
179
180 .. tip:: The difference between This and Self is that Self point to the current active object that we can change using braces.
181
182 Remember that in most cases we don't need to use This or Self in the class region
183
184 We can write
185
186
187 .. code-block:: ring
188
189         class program name version
190
191 Or 
192
193 .. code-block:: ring
194
195         class program name="My Application" version="1.0"
196
197 .. note:: We use This or Self in the class region just to avoid conflict with global variables that are defined with the same name.
198
199
200 .. index:: 
201         pair: What is new in Ring 1.8?; Default value for object attributes is NULL
202
203 Default value for object attributes is NULL
204 ===========================================
205
206 Starting from Ring 1.8 the default value for object attributes is NULL
207
208 In Ring, the NULL value is just an empty string or a string that contains "NULL"
209
210 We can check for NULL values using the isNULL() function
211
212 Example:
213
214 .. code-block:: ring
215
216         oProgram = new Program
217         ? oProgram.name
218         ? oProgram.version
219         ? isNULL(oProgram.name)
220         ? isNULL(oProgram.version)
221         oProgram { name="My Application" version="1.0" }
222         ? isNULL(oProgram.name)
223         ? isNULL(oProgram.version)
224         ? oProgram
225
226         class program
227                 name 
228                 version
229
230 Output:
231
232 .. code-block:: none
233
234         NULL
235         NULL
236         1
237         1
238         0
239         0
240         name: My Application
241         version: 1.0
242
243 In previous versions of Ring, trying to access the object attribute before assigning a value to it
244
245 Will lead to runtime error and you can't check it using isnull() 
246
247 The only way was assigning a value or using try/catch/end 
248
249 We changed this behavior so we can have full control in seamless way.
250
251
252 .. index:: 
253         pair: What is new in Ring 1.8?; The For Loops uses the local scope
254
255 The For Loops uses the local scope
256 ==================================
257
258 In Ring 1.8, when the For Loop defines new identifier (variable) it will define it in the local scope.
259
260 Example:
261
262 .. code-block:: ring
263
264         x = 10
265         ? x             # Print 10
266         test1()
267         ? x             # Print 10
268         test2()
269         ? x             # Print 10
270
271         func test1
272                 for x = 1 to 5
273                 next
274                 ? x     # Print 6
275
276         func test2
277                 list = 1:5
278                 for x in list
279                 next
280                 ? x     # Print NULL (The "For In" loop will kill the reference after the loop)
281
282 Output:
283
284 .. code-block:: ring
285
286         10
287         6
288         10
289         NULL
290         10      
291                 
292 .. index:: 
293         pair: What is new in Ring 1.8?; Merge binary characters
294
295 Merge binary characters
296 =======================
297
298 From Ring 1.0 we can create binary strings and do operations on these strings.
299
300 Now in Ring 1.8, we can get individual characters from these strings and merge them together using
301 the '+' operator.
302
303 Example:
304
305 .. code-block:: ring
306
307         cStr = "Welcome"
308         ? cstr[1] + cstr[2] + cStr[5]
309         v = cstr[1] + cstr[2] + cStr[5]
310         ? v
311         ? len(v)
312         c1 = cStr[1]
313         ? c1
314         aList = [1,2,3]
315         cStr = ""
316         for item in aList 
317                 cStr += int2bytes(item)
318         next 
319         ? "All String"
320         ? len(cStr)
321         ? "First Part"
322         n1 = cStr[1] + cStr[2] + cStr[3] + cStr[4]
323         ? len(n1)
324         ? "Second Part"
325         n2 = cStr[5] + cStr[6] + cStr[7] + cStr[8]
326         ? len(n2)
327         ? "Third Part"
328         n3 = cStr[9] + cStr[10] + cStr[11] + cStr[12]
329         ? len(n3)
330         ? "All String"
331         cString = cStr[1] + cStr[2] + cStr[3] + cStr[4] + 
332                   cStr[5] + cStr[6] + cStr[7] + cStr[8] + 
333                   cStr[9] + cStr[10] + cStr[11] + cStr[12]
334         ? len(cString)
335         ? ascii(cStr[1])
336         ? len(cStr[2])
337
338 Output:
339
340 .. code-block:: ring
341
342         Weo
343         Weo
344         3
345         W
346         All String
347         12
348         First Part
349         4
350         Second Part
351         4       \ 2
352         Third Part
353         4
354         All String
355         12
356         1
357         1
358         
359
360 .. index:: 
361         pair: What is new in Ring 1.8?; FoxRing Library
362
363 FoxRing Library
364 ===============
365
366 Developer: Jose Rosado
367
368 A class with some of the functions I used in FoxPro\
369
370 Example:
371
372 .. code-block:: ring
373
374         Load "foxring.ring"
375
376         mf = new frFunctions
377         ? mf.frAbs(-45)      
378         ? mf.frAbs(10-30)    
379         ? mf.frAbs(30-10)   
380
381         ? mf.frTransform("    Ring is a good language    ",
382                          "@! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") 
383         ? mf.frAllTrim("    Ring is a good language    ", Null) 
384
385 Output:
386
387 .. code-block:: ring
388
389         45
390         20
391         20
392             RING IS A GOOD LANGUAGE
393         Ring is a good language
394
395
396 .. index:: 
397         pair: What is new in Ring 1.8?; Better Form Designer
398
399 Better Form Designer
400 ====================
401
402 (1) Layout Control - Display the control name when loading forms.
403 (2) Button Control - Display the button images written using relative path.
404 (3) Table  Control - Display the control name when loading forms.
405 (4) Better behavior in "Bring to front" and "Send to back" operations.
406 (5) New buttons are added to the toolbar (Duplicate, Bring to front, Send to back, Delete).
407 (6) Using layouts in (Menubar designer, Window Flags window, Selecting Objects window).
408 (7) Better behavior for displaying the properties window when changing the selected objects.
409 (8) New buttons are added to move and resize multiple selection of objects.
410 (9) Window Properties - Add button to select the layout.
411 (10) Opening forms and switching between files is faster.
412 (11) Objects Order window.
413 (12) Select Objects window.
414 (13) When we change the control name, the name will be updated in layout objects.
415
416 .. index:: 
417         pair: What is new in Ring 1.8?; Better Cards Game
418
419 Better Cards Game
420 =================
421
422 The Cards game is updated and we can play with the Computer
423
424 .. image:: cardsmainmenu.png
425         :alt: Cards Main Menu
426
427 .. index:: 
428         pair: What is new in Ring 1.8?; Better RingQt
429
430 Better RingQt
431 =============
432
433 * The next classes are added to RingQt
434
435 (1) QTabBar
436 (2) QFile
437 (3) QFileDevice
438 (4) QStandardPaths
439 (5) QDir
440 (6) QQuickWidget
441 (7) QQmlError
442 (8) QScrollBar
443
444 * RingQt for Android is updated to support modern versions of Qt
445
446 Tested using
447
448 (1) Qt 5.5.1
449 (2) Qt 5.9.5
450 (3) Qt 5.11.0
451
452 * In RingQt for Android, The Ring Object File (ringo) will be executed directly from resources.
453
454
455 .. index:: 
456         pair: What is new in Ring 1.8?; Better Code Generator For Extensions
457
458 Better Code Generator For Extensions
459 ====================================
460
461 New Option: StaticMethods
462
463 Starting from Ring 1.8 the code generator support the staticmethods option.
464
465 So the code generator can know that the class doesn't need an object to call the methods.
466
467 Example:
468
469 .. code-block:: none
470
471         <class>
472         name: QStandardPaths
473         para: void
474         nonew
475         staticmethods
476         </class>
477
478         QString displayName(QStandardPaths::StandardLocation type)
479         QString findExecutable(QString executableName, QStringList paths))
480
481
482 .. index:: 
483         pair: What is new in Ring 1.8?; Better Ring Compiler and VM
484
485 Better Ring Compiler and VM
486 ===========================
487
488 (1) Better loading for files in relative paths
489 (2) Code Optimization for eval() function 
490 (3) Better Memory Pool
491 (4) When embedding Ring in Ring, the error in the hosted environment will not close the host
492
493 Example:
494
495 .. code-block:: ring
496
497         ? "Start the test!" 
498
499         pState = ring_state_init()
500
501         ring_state_runcode(pState," ? 'Let us try having an error' ? x")
502
503         ring_state_delete(pState)
504
505         ? ""
506         ? "End of test!"
507
508 Output:
509
510 .. code-block:: none
511
512         Start the test!
513         Let us try having an error
514
515         Line 1 Error (R24) : Using uninitialized variable : x
516         in file Ring_EmbeddedCode
517         End of test!
518         
519 (5) The compiler will ignore new lines after keywords that expect tokens after it
520
521 Example:
522
523 .. code-block:: ring
524
525         see 
526         "
527                 Hello, World!
528         "
529         test()
530
531         func 
532         #======================#
533                 Test
534         #======================#
535
536                 ?
537                 "
538         
539                 Hello from the Test function
540
541                 "
542
543 Output:
544
545 .. code-block:: none
546
547
548                 Hello, World!
549
550
551                 Hello from the Test function
552
553 (6) Better code (faster) for the main loop, special loop for eval() function.
554 (7) Better code (faster) for tracking C pointers to avoid using NULL pointers.
555 (8) Better code (faster) for getting the self object using braces.
556
557 .. index:: 
558         pair: What is new in Ring 1.8?; Notes to extensions creators
559
560 Notes to extensions creators
561 ============================
562
563 If you have created new extensions for Ring in the C/C++ languages.
564
565 You have to rebuild your extension (Generate the DLL file again using Ring 1.8 header files) before usage with Ring 1.8
566
567 Because we changed the internal structure of the VM, but no changes to the code are required. just rebuild.