SlideShare une entreprise Scribd logo
1  sur  10
Télécharger pour lire hors ligne
36.2 MySQL_Init() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
36.3 MySQL_Error() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
36.4 MySQL_Connect() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
36.5 MySQL_Close() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
36.6 MySQL_Query() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
36.7 Create Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238
36.8 Create Table and Insert Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238
36.9 MySQL_Insert_ID() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
36.10 MySQL_Result() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240
36.11 MySQL_Next_Result() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240
36.12 Print Query Result . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240
36.13 MySQL_Columns() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240
36.14 MySQL_Result2() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241
36.15 MySQL_Escape_String() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242
36.16 Save Image inside the database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242
36.17 Restore Image From The Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243
36.18 MySQL_AutoCommit() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243
36.19 MySQL_Commit() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243
36.20 MySQL_Rollback() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243
36.21 Transaction Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243
37 SQLite Functions 245
37.1 sqlite_init() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
37.2 sqlite_open() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
37.3 sqlite_execute() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
37.4 sqlite_close() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
37.5 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246
38 Security and Internet Functions 248
38.1 MD5() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248
38.2 SHA1() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
38.3 SHA256() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
38.4 SHA512() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
38.5 SHA384() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250
38.6 SHA224() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250
38.7 Encrypt() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250
38.8 Decrypt() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251
38.9 Encryption and Decryption Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251
38.10 File Hash . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251
38.11 Randbytes() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252
38.12 Download() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252
38.13 SendEmail() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252
39 Object Oriented Programming (OOP) 253
39.1 Classes and Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253
39.2 Access Objects Using Braces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255
39.3 Composition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256
39.4 Setter and Getter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
39.5 Private Attributes and Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
39.6 Operator Overloading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258
39.7 Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259
39.8 Dynamic Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260
39.9 Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260
39.10 Printing Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261
ix
39.11 Find() and List of Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261
39.12 Sort() and list of objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262
39.13 Using Self.Attribute and Self.Method() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264
39.14 Using This.Attribute and This.Method() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265
40 Functional Programming 266
40.1 Pure Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266
40.2 First-class Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267
40.3 Higher-order Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267
40.4 Anonymous and Nested Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268
40.5 Equality of functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
41 Reflection and Meta-programming 271
41.1 locals() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271
41.2 globals() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271
41.3 functions() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272
41.4 cfunctions() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272
41.5 islocal() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273
41.6 isglobal() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273
41.7 isfunction() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274
41.8 iscfunction() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274
41.9 packages() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275
41.10 ispackage() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275
41.11 classes() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276
41.12 isclass() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276
41.13 packageclasses() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277
41.14 ispackageclass() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278
41.15 classname() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278
41.16 objectid() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279
41.17 isobject() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279
41.18 attributes() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279
41.19 methods() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279
41.20 isattribute() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280
41.21 isprivateattribute() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280
41.22 ismethod() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281
41.23 isprivatemethod() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281
41.24 addattribute() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282
41.25 addmethod() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282
41.26 getattribute() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284
41.27 setattribute() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285
41.28 mergemethods() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286
41.29 packagename() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287
42 Stdlib Functions 288
42.1 puts() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288
42.2 print() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288
42.3 Print2Str() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288
42.4 getstring() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289
42.5 getnumber() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289
42.6 apppath() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289
42.7 justfilepath() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289
42.8 justfilename() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290
42.9 value() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290
42.10 times() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290
x
42.11 map() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291
42.12 filter() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291
42.13 split() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291
42.14 splitmany() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292
42.15 newlist() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292
42.16 capitalized() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292
42.17 isspecial() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293
42.18 isvowel() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293
42.19 linecount() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293
42.20 factorial() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293
42.21 fibonacci() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294
42.22 isprime() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294
42.23 sign() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294
42.24 list2file() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295
42.25 file2list() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295
42.26 startswith() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295
42.27 endswith() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295
42.28 gcd() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296
42.29 lcm() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296
42.30 sumlist() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296
42.31 prodlist() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297
42.32 evenorodd() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297
42.33 factors() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297
42.34 palindrome() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298
42.35 isleapyear() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298
42.36 binarydigits() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298
42.37 matrixmulti() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299
42.38 matrixtrans() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299
42.39 dayofweek() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299
42.40 permutation() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300
42.41 readline() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300
42.42 substring() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300
42.43 changestring() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301
42.44 sleep() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301
42.45 ismainsourcefile() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301
42.46 direxists() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302
42.47 makedir() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302
42.48 fsize() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302
42.49 trimall() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302
42.50 trimleft() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303
42.51 trimright() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303
42.52 epochtime() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303
42.53 SystemCmd() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303
42.54 ListAllFiles() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303
43 Stdlib Classes 305
43.1 StdBase Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305
43.2 String Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306
43.3 List Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 308
43.4 Stack Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310
43.5 Queue Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310
43.6 HashTable Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311
43.7 Tree Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312
43.8 Math Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313
xi
43.9 DateTime Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317
43.10 File Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 318
43.11 System Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319
43.12 Debug Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320
43.13 DataType Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321
43.14 Conversion Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322
43.15 ODBC Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323
43.16 MySQL Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324
43.17 SQLite Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325
43.18 Security Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 326
43.19 Internet Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327
44 Declarative Programming using Nested Structures 328
44.1 Creating Objects inside Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328
44.2 Composition and Returning Objects and Lists by Reference . . . . . . . . . . . . . . . . . . . . . . 329
44.3 Executing code after the end of object access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331
44.4 Declarative Programming on the top of Object-Oriented . . . . . . . . . . . . . . . . . . . . . . . . 331
44.5 More beautiful Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332
45 Natural Language Programming 334
45.1 History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334
45.2 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334
45.3 Change the Ring Keyword ‘And’ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335
45.4 Change the Ring Operator ‘+’ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336
45.5 Change the ‘=’ operator to ‘is’ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337
45.6 Using Eval() with our Natural Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 338
45.7 BraceStart and BraceEnd Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 339
45.8 BraceExprEval Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 340
45.9 Real Natural Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 340
45.10 BraceError() Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341
45.11 Clean Natural Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 342
46 Using the Natural Library 344
46.1 Natural Library - Demo Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 344
46.2 Defining Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346
46.3 Natural Library - Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349
46.4 Defining commands using classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349
47 Web Development (CGI Library) 351
47.1 Configure the Apache web server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351
47.2 Ring CGI Hello World Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352
47.3 Hello World Program using the Web Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352
47.4 Web Library Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353
47.5 HTTP Get Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353
47.6 HTTP POST Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 358
47.7 Upload Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360
47.8 Cookies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 363
47.9 URL Encode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365
47.10 Templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 366
47.11 HTML Special Characters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 368
47.12 Hash Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369
47.13 Random Image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371
47.14 HTML Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 372
47.15 HTML Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 374
47.16 Gradient . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375
xii
47.17 Generating Pages using Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 376
47.18 HtmlPage Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 380
47.19 Using Bootstrap Library using Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381
47.20 Using Bootstrap Library using Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 382
47.21 CRUD Example using MVC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385
47.22 Users registration and Login . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 387
47.23 Database, ModelBase & ControllerBase classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393
47.24 WebLib API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 398
47.25 Application Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400
47.26 Page Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400
47.27 ScriptFunctions Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 402
47.28 StyleFunctions Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403
47.29 WebPage Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403
47.30 HtmlPage Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 404
48 Using RingLibCurl 405
48.1 Get Request . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 405
48.2 Post Request . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 405
48.3 Facebook Login . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 405
48.4 Save Output to String . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 406
48.5 Get Stock Data From Yahoo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 407
49 Using RingZip 409
49.1 Create Zip File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 409
49.2 Extract Zip File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 409
49.3 Print Files in Zip file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 409
49.4 Using RingZip Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 409
49.5 Zip Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 411
49.6 ZipEntry Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 411
50 Graphics and 2D Games programming using RingAllegro 412
50.1 Drawing, Animation and Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 412
50.2 Using TrueType Fonts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 418
50.3 Playing Sound Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 419
50.4 Scaling and Rotating Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 420
50.5 Display Transparent Image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 421
50.6 Using Threads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 422
51 Using RingLibSDL 425
51.1 Create Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425
51.2 Display Image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425
51.3 Switch between two images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 426
51.4 Draw Rectangle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 426
51.5 Display PNG Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427
51.6 Use TTF Fonts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427
51.7 Display Transparent Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427
51.8 Close Window Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 428
51.9 Mouse Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429
51.10 Play Sound . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 430
52 Demo Project - Game Engine for 2D Games 432
52.1 Project Layers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 432
52.2 Graphics Library bindings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 432
52.3 Interface to graphics library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433
52.4 Game Engine Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433
xiii
52.5 Games Layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433
52.6 Game Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 434
52.7 GameObject Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 434
52.8 Sprite Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 435
52.9 Text Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 435
52.10 Animate Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 436
52.11 Sound Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 436
52.12 Map Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 436
52.13 Using the Game Engine - Creating the Game Window . . . . . . . . . . . . . . . . . . . . . . . . . 437
52.14 Using the Game Engine - Drawing Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 437
52.15 Using the Game Engine - Moving Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 438
52.16 Using the Game Engine - Playing Sound . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 440
52.17 Using the Game Engine - Animation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 441
52.18 Using the Game Engine - Animation and Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . 442
52.19 Using the Game Engine - Sprite - Automatic Movement using Keyboard . . . . . . . . . . . . . . . 444
52.20 Using the Game Engine - Sprite - Keypress event . . . . . . . . . . . . . . . . . . . . . . . . . . . . 445
52.21 Using the Game Engine - Sprite - Mouse event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 445
52.22 Using the Game Engine - Sprite - State event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 446
52.23 Using the Game Engine - Animate - Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 447
52.24 Using the Game Engine - Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 449
52.25 Using the Game Engine - Map Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 451
52.26 Using the Game Engine - Object and Drawing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 452
52.27 Stars Fighter Game . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 455
52.28 Flappy Bird 3000 Game . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 463
52.29 Super Man 2016 Game . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 470
53 Building Games For Android 482
53.1 Download Requirements and Update the Android SDK . . . . . . . . . . . . . . . . . . . . . . . . . 482
53.2 Project Folder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 482
53.3 Building the project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 483
54 Using RingOpenGL and RingFreeGLUT for 3D Graphics 485
54.1 Samples Source (Authors) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 485
54.2 What is RingOpenGL? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 485
54.3 What is RingFreeGLUT? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 486
54.4 The First Window using RingFreeGLUT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 486
54.5 Drawing using RingOpenGL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 487
54.6 The First Triangle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 489
54.7 Window Resize Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 490
54.8 Triangle Rotation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 491
54.9 Keyboard Events and Colors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 492
54.10 The Camera . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 495
54.11 Mouse Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 502
54.12 Menu Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 505
54.13 Using Fonts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 512
54.14 Frames Per Second . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 520
54.15 Make a Cube using RingOpenGL and RingFreeGLUT . . . . . . . . . . . . . . . . . . . . . . . . . 529
55 Desktop and Mobile development using RingQt 533
55.1 The First GUI Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 533
55.2 Using Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 535
55.3 Using the QTextEdit Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 536
55.4 Using the QListWidget Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 537
55.5 Using QTreeView and QFileSystemModel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 540
xiv
55.6 Using QTreeWidget and QTreeWidgetItem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 541
55.7 Using QComboBox Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 542
55.8 Creating Menubar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 543
55.9 Creating Toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 546
55.10 Creating StatusBar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 547
55.11 Using QDockWidget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 548
55.12 Using QTabWidget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 550
55.13 Using QTableWidget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 551
55.14 Using QProgressBar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 552
55.15 Using QSpinBox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 553
55.16 Using QSlider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 554
55.17 Using QDateEdit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 555
55.18 Using QDial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 556
55.19 Using QWebView . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 559
55.20 Using QCheckBox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 560
55.21 Using QRadioButton and QButtonGroup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 561
55.22 Adding Hyperlink to QLabel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 563
55.23 QVideoWidget and QMediaPlayer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 564
55.24 Using QFrame . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 566
55.25 Display Image using QLabel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 567
55.26 Menubar and StyleSheet Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 568
55.27 QLineEdit Events and QMessageBox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 570
55.28 Other Widgets Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 572
55.29 Using the QTimer Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 574
55.30 Using QProgressBar and Timer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 575
55.31 Display Scaled Image using QLabel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 576
55.32 Using the QFileDialog Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 577
55.33 Drawing using QPainter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 578
55.34 Printing using QPrinter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 580
55.35 Creating More than one Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 581
55.36 Playing Sound . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 582
55.37 Using the QColorDialog Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 582
55.38 Using qLCDNumber Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 584
55.39 Movable Label Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 584
55.40 QMessagebox Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 585
55.41 Using QInputDialog Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 586
55.42 Dialog Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 588
55.43 KeyPress and Mouse Move Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 589
55.44 Moving Objects using the Mouse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 590
55.45 Inheritance from GUI Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 594
55.46 Using QDesktopWidget Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 595
55.47 Rotate Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 596
55.48 Change Focus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 598
55.49 Regular Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 599
55.50 Simple Client and Server Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 600
55.51 Dynamic Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 602
55.52 Weight History Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 603
55.53 Notepad Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 607
55.54 The Cards Game . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 622
55.55 Classes and their Methods to use the default events . . . . . . . . . . . . . . . . . . . . . . . . . . . 628
55.56 Methods to use Events with Events Filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 631
55.57 The Difference between Qt and RingQt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 632
55.58 RingQt Classes and their Qt Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 633
55.59 New Classes names - Index Start from 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 633
xv
55.60 Creating Reports using the WebLib and the GUILib . . . . . . . . . . . . . . . . . . . . . . . . . . 634
56 Building RingQt Applications for Mobile 637
56.1 Download Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 637
56.2 Update the Android SDK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 637
56.3 Install Qt for Android . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 637
56.4 Comments about developing for Android using RingQt . . . . . . . . . . . . . . . . . . . . . . . . . 638
57 Objects Library for RingQt Application 640
57.1 Library Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 640
57.2 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 640
57.3 Open_WindowAndLink() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 643
57.4 Open_WindowInPackages() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 644
57.5 Objects Library Source Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 644
58 Using the Form Designer 645
58.1 The Designer Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 646
58.2 The Toolbox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 646
58.3 The Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 646
58.4 Running Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 647
58.5 Events Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 647
58.6 Keyboard Shortcuts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 650
58.7 Menubar Designer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 650
58.8 Window Flags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 651
58.9 Entering Items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 652
58.10 Using Layouts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 652
58.11 More Samples and Tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 652
59 Scope Rules for Variables and Attributes 653
59.1 Three Scopes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 653
59.2 Defining Variables and Variables Access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 653
59.3 How Ring find the variable? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 654
59.4 Using Object.Attribute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 654
59.5 The Self Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 654
59.6 How Ring Define Variables and Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 655
59.7 Conflict between Global Variables and Class Attributes . . . . . . . . . . . . . . . . . . . . . . . . . 655
59.8 Conflict between Class Attributes and Local Variables . . . . . . . . . . . . . . . . . . . . . . . . . 656
59.9 Using Braces to access objects inside Class Methods . . . . . . . . . . . . . . . . . . . . . . . . . . 657
59.10 Accessing the class attributes from braces inside class methods . . . . . . . . . . . . . . . . . . . . 660
59.11 Creating a Class for each Window in GUI applications . . . . . . . . . . . . . . . . . . . . . . . . . 661
59.12 Conflict between self inside braces and self in the class region . . . . . . . . . . . . . . . . . . . . . 662
59.13 Using braces to escape from the current object scope . . . . . . . . . . . . . . . . . . . . . . . . . . 665
59.14 Summary of Scope Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 666
60 Scope Rules for Functions and Methods 668
60.1 How Ring find the Functions and Methods? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 668
60.2 Example about Sharing Names between Functions and Methods . . . . . . . . . . . . . . . . . . . . 669
60.3 Calling a function sharing the name with a method in the current class . . . . . . . . . . . . . . . . . 670
61 Syntax Flexibility 672
61.1 Change Language Keywords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 672
61.2 Change Language Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 673
61.3 Load Syntax Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 674
61.4 Using “()” around the function parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 675
61.5 Using Semi-colon after and between statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 675
xvi
61.6 Using $ and @ in the start of the variable name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 676
61.7 Using the ‘elseif’ keyword as ‘but’ in if statement . . . . . . . . . . . . . . . . . . . . . . . . . . . 676
61.8 Using the ‘else’ keyword as ‘other’ in switch statement . . . . . . . . . . . . . . . . . . . . . . . . . 677
61.9 Using the ‘end’ keyword in different control structures . . . . . . . . . . . . . . . . . . . . . . . . . 677
61.10 Using braces to start and end different control structures . . . . . . . . . . . . . . . . . . . . . . . . 678
61.11 Using ‘put’ and ‘get’ as ‘see’ and ‘give’ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 679
61.12 Using ‘case’ as ‘on’ in switch statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 679
61.13 Using ‘def’ as ‘func’ in functions/methods definition . . . . . . . . . . . . . . . . . . . . . . . . . . 680
61.14 Using braces { } in Packages/Classes/Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 680
61.15 Using ‘end’ keyword after Packages/Classes/Functions . . . . . . . . . . . . . . . . . . . . . . . . . 680
61.16 Using ‘endpackage’/’endclass’/’endfunc’ keywords after Packages/Classes/Functions . . . . . . . . 681
62 Introduction to the Type Hints Library 682
62.1 Why Type Hints? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 682
62.2 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 682
62.3 User Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 682
62.4 Using Types inside Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 683
62.5 Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 683
63 Distributing Ring Applications 685
63.1 Distributing Applications for Microsoft Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . 685
63.2 Protecting the Source Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 685
63.3 Creating Windows Installer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 686
63.4 Using C/C++ Compiler and Linker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 686
63.5 Distributing Applications and Games for Mobile . . . . . . . . . . . . . . . . . . . . . . . . . . . . 686
64 Command Line Options 687
64.1 Printing Tokens . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 687
64.2 Printing Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 689
64.3 Printing Intermediate Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 693
64.4 Printing Final Intermediate Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 696
64.5 CGI Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 700
64.6 No Run . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 700
64.7 Printing Instruction Operation Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 700
64.8 Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 700
64.9 Generate Object File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 701
65 Low Level Functions 702
65.1 callgc() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 703
65.2 varptr() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 703
65.3 space() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 703
65.4 nullpointer() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 704
65.5 object2pointer() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 704
65.6 pointer2object() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 704
65.7 ptrcmp() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 705
65.8 ringvm_cfunctionslist() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 706
65.9 ringvm_functionslist() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 706
65.10 ringvm_classeslist() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 707
65.11 ringvm_packageslist() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 707
65.12 ringvm_memorylist() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 708
65.13 ringvm_calllist() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 710
65.14 ringvm_fileslist() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 711
65.15 ringvm_settrace() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 712
65.16 ringvm_tracedata() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 712
65.17 ringvm_traceevent() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 712
xvii
65.18 ringvm_tracefunc() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 713
65.19 ringvm_scopescount() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 713
65.20 ringvm_evalinscope() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 713
65.21 ringvm_passerror() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 713
65.22 ringvm_hideerrormsg() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 713
65.23 ringvm_callfunc() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 714
65.24 Example - Using the Trace Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 714
65.25 Example - The Trace Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 718
66 The Trace Library and the Interactive Debugger 722
66.1 Loading the Trace library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 722
66.2 Trace All Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 722
66.3 Trace control flow between functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 722
66.4 Pass Error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 723
66.5 Interactive Debugger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 723
66.6 Execute Program Line by Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 723
66.7 BreakPoint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 724
66.8 Disable BreakPoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 724
66.9 Using the Interactive Debugger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 724
67 Embedding Ring in Ring 727
67.1 Embedding Ring in Ring without sharing the State . . . . . . . . . . . . . . . . . . . . . . . . . . . 727
67.2 Serial Execution of Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 728
68 Extension using the C/C++ languages 729
68.1 ring_ext.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 729
68.2 ring_ext.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 729
68.3 Module Organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 730
68.4 Function Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 731
68.5 Check Parameters Count . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 731
68.6 Display Error Message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 732
68.7 Check Parameters Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 732
68.8 Get Parameters Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 732
68.9 Return Value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 733
68.10 Function Prototype . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 733
68.11 Sin() Function Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 733
68.12 Fopen() and Fclose() Functions Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 733
68.13 Ring API - List Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 734
68.14 Ring API - String Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 736
68.15 MySQL_Columns() Function Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 736
68.16 Dynamic/Shared Libraries (DLL/So) and LoadLib() function . . . . . . . . . . . . . . . . . . . . . 737
69 Embedding Ring Language in C/C++ Programs 739
69.1 Ring State . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 739
69.2 Ring State Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 739
69.3 Ring State Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 740
70 Code Generator for wrapping C/C++ Libraries 742
70.1 Using the tool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 742
70.2 Configuration file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 742
70.3 Using the function prototype . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 742
70.4 Adding code to the generated code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 744
70.5 Prefix for Functions Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 744
70.6 Generate function to wrap structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 744
70.7 Determine Structure Members Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 745
xviii

Contenu connexe

Tendances

Architectures logicielles et materielles
Architectures logicielles et materiellesArchitectures logicielles et materielles
Architectures logicielles et materielles
Adnane Farid
 

Tendances (20)

The Ring programming language version 1.9 book - Part 2 of 210
The Ring programming language version 1.9 book - Part 2 of 210The Ring programming language version 1.9 book - Part 2 of 210
The Ring programming language version 1.9 book - Part 2 of 210
 
The Ring programming language version 1.10 book - Part 2 of 212
The Ring programming language version 1.10 book - Part 2 of 212The Ring programming language version 1.10 book - Part 2 of 212
The Ring programming language version 1.10 book - Part 2 of 212
 
The Ring programming language version 1.7 book - Part 3 of 196
The Ring programming language version 1.7 book - Part 3 of 196The Ring programming language version 1.7 book - Part 3 of 196
The Ring programming language version 1.7 book - Part 3 of 196
 
Cours matlab
Cours matlabCours matlab
Cours matlab
 
The Ring programming language version 1.10 book - Part 3 of 212
The Ring programming language version 1.10 book - Part 3 of 212The Ring programming language version 1.10 book - Part 3 of 212
The Ring programming language version 1.10 book - Part 3 of 212
 
The Ring programming language version 1.8 book - Part 3 of 202
The Ring programming language version 1.8 book - Part 3 of 202The Ring programming language version 1.8 book - Part 3 of 202
The Ring programming language version 1.8 book - Part 3 of 202
 
The Ring programming language version 1.9 book - Part 3 of 210
The Ring programming language version 1.9 book - Part 3 of 210The Ring programming language version 1.9 book - Part 3 of 210
The Ring programming language version 1.9 book - Part 3 of 210
 
Bedhboperation r41 fr
Bedhboperation r41 frBedhboperation r41 fr
Bedhboperation r41 fr
 
The Ring programming language version 1.4 book - Part 1 of 30
The Ring programming language version 1.4 book - Part 1 of 30The Ring programming language version 1.4 book - Part 1 of 30
The Ring programming language version 1.4 book - Part 1 of 30
 
The Ring programming language version 1.4.1 book - Part 1 of 31
The Ring programming language version 1.4.1 book - Part 1 of 31The Ring programming language version 1.4.1 book - Part 1 of 31
The Ring programming language version 1.4.1 book - Part 1 of 31
 
Ovidentia Guide Utilisateur
Ovidentia Guide UtilisateurOvidentia Guide Utilisateur
Ovidentia Guide Utilisateur
 
Algo
AlgoAlgo
Algo
 
The Ring programming language version 1.5.2 book - Part 1 of 181
The Ring programming language version 1.5.2 book - Part 1 of 181The Ring programming language version 1.5.2 book - Part 1 of 181
The Ring programming language version 1.5.2 book - Part 1 of 181
 
The Ring programming language version 1.5.3 book - Part 1 of 184
The Ring programming language version 1.5.3 book - Part 1 of 184The Ring programming language version 1.5.3 book - Part 1 of 184
The Ring programming language version 1.5.3 book - Part 1 of 184
 
Architectures logicielles et materielles
Architectures logicielles et materiellesArchitectures logicielles et materielles
Architectures logicielles et materielles
 
The Ring programming language version 1.10 book - Part 1 of 212
The Ring programming language version 1.10 book - Part 1 of 212The Ring programming language version 1.10 book - Part 1 of 212
The Ring programming language version 1.10 book - Part 1 of 212
 
Deviens un Ninja avec Angular2
Deviens un Ninja avec Angular2Deviens un Ninja avec Angular2
Deviens un Ninja avec Angular2
 
The Ring programming language version 1.5.4 book - Part 1 of 185
The Ring programming language version 1.5.4 book - Part 1 of 185The Ring programming language version 1.5.4 book - Part 1 of 185
The Ring programming language version 1.5.4 book - Part 1 of 185
 
The Ring programming language version 1.9 book - Part 1 of 210
The Ring programming language version 1.9 book - Part 1 of 210The Ring programming language version 1.9 book - Part 1 of 210
The Ring programming language version 1.9 book - Part 1 of 210
 
Cbdsys 2
Cbdsys 2Cbdsys 2
Cbdsys 2
 

Similaire à The Ring programming language version 1.5.1 book - Part 2 of 180

Similaire à The Ring programming language version 1.5.1 book - Part 2 of 180 (13)

Matlab for engineer
Matlab for engineer Matlab for engineer
Matlab for engineer
 
Base-de-données.pdf
Base-de-données.pdfBase-de-données.pdf
Base-de-données.pdf
 
Rapport PFE Ilef Ben Slima
Rapport PFE Ilef Ben SlimaRapport PFE Ilef Ben Slima
Rapport PFE Ilef Ben Slima
 
Introduction à MATLAB
Introduction à MATLABIntroduction à MATLAB
Introduction à MATLAB
 
Tp sgbd gsi
Tp sgbd gsiTp sgbd gsi
Tp sgbd gsi
 
The Ring programming language version 1.8 book - Part 1 of 202
The Ring programming language version 1.8 book - Part 1 of 202The Ring programming language version 1.8 book - Part 1 of 202
The Ring programming language version 1.8 book - Part 1 of 202
 
Automatisme) www.cours-online.com
Automatisme) www.cours-online.comAutomatisme) www.cours-online.com
Automatisme) www.cours-online.com
 
Introduction aux systèmes automatisés
Introduction aux systèmes automatisésIntroduction aux systèmes automatisés
Introduction aux systèmes automatisés
 
Oracle 11g exploitation
Oracle 11g exploitationOracle 11g exploitation
Oracle 11g exploitation
 
The Ring programming language version 1.3 book - Part 1 of 88
The Ring programming language version 1.3 book - Part 1 of 88The Ring programming language version 1.3 book - Part 1 of 88
The Ring programming language version 1.3 book - Part 1 of 88
 
cours_python.pdf
cours_python.pdfcours_python.pdf
cours_python.pdf
 
The Ring programming language version 1.2 book - Part 1 of 84
The Ring programming language version 1.2 book - Part 1 of 84The Ring programming language version 1.2 book - Part 1 of 84
The Ring programming language version 1.2 book - Part 1 of 84
 
Ibm spectrum archive enterprise edition
Ibm spectrum archive enterprise editionIbm spectrum archive enterprise edition
Ibm spectrum archive enterprise edition
 

Plus de Mahmoud Samir Fayed

Plus de Mahmoud Samir Fayed (20)

The Ring programming language version 1.10 book - Part 212 of 212
The Ring programming language version 1.10 book - Part 212 of 212The Ring programming language version 1.10 book - Part 212 of 212
The Ring programming language version 1.10 book - Part 212 of 212
 
The Ring programming language version 1.10 book - Part 211 of 212
The Ring programming language version 1.10 book - Part 211 of 212The Ring programming language version 1.10 book - Part 211 of 212
The Ring programming language version 1.10 book - Part 211 of 212
 
The Ring programming language version 1.10 book - Part 210 of 212
The Ring programming language version 1.10 book - Part 210 of 212The Ring programming language version 1.10 book - Part 210 of 212
The Ring programming language version 1.10 book - Part 210 of 212
 
The Ring programming language version 1.10 book - Part 208 of 212
The Ring programming language version 1.10 book - Part 208 of 212The Ring programming language version 1.10 book - Part 208 of 212
The Ring programming language version 1.10 book - Part 208 of 212
 
The Ring programming language version 1.10 book - Part 207 of 212
The Ring programming language version 1.10 book - Part 207 of 212The Ring programming language version 1.10 book - Part 207 of 212
The Ring programming language version 1.10 book - Part 207 of 212
 
The Ring programming language version 1.10 book - Part 205 of 212
The Ring programming language version 1.10 book - Part 205 of 212The Ring programming language version 1.10 book - Part 205 of 212
The Ring programming language version 1.10 book - Part 205 of 212
 
The Ring programming language version 1.10 book - Part 206 of 212
The Ring programming language version 1.10 book - Part 206 of 212The Ring programming language version 1.10 book - Part 206 of 212
The Ring programming language version 1.10 book - Part 206 of 212
 
The Ring programming language version 1.10 book - Part 204 of 212
The Ring programming language version 1.10 book - Part 204 of 212The Ring programming language version 1.10 book - Part 204 of 212
The Ring programming language version 1.10 book - Part 204 of 212
 
The Ring programming language version 1.10 book - Part 203 of 212
The Ring programming language version 1.10 book - Part 203 of 212The Ring programming language version 1.10 book - Part 203 of 212
The Ring programming language version 1.10 book - Part 203 of 212
 
The Ring programming language version 1.10 book - Part 202 of 212
The Ring programming language version 1.10 book - Part 202 of 212The Ring programming language version 1.10 book - Part 202 of 212
The Ring programming language version 1.10 book - Part 202 of 212
 
The Ring programming language version 1.10 book - Part 201 of 212
The Ring programming language version 1.10 book - Part 201 of 212The Ring programming language version 1.10 book - Part 201 of 212
The Ring programming language version 1.10 book - Part 201 of 212
 
The Ring programming language version 1.10 book - Part 200 of 212
The Ring programming language version 1.10 book - Part 200 of 212The Ring programming language version 1.10 book - Part 200 of 212
The Ring programming language version 1.10 book - Part 200 of 212
 
The Ring programming language version 1.10 book - Part 199 of 212
The Ring programming language version 1.10 book - Part 199 of 212The Ring programming language version 1.10 book - Part 199 of 212
The Ring programming language version 1.10 book - Part 199 of 212
 
The Ring programming language version 1.10 book - Part 198 of 212
The Ring programming language version 1.10 book - Part 198 of 212The Ring programming language version 1.10 book - Part 198 of 212
The Ring programming language version 1.10 book - Part 198 of 212
 
The Ring programming language version 1.10 book - Part 197 of 212
The Ring programming language version 1.10 book - Part 197 of 212The Ring programming language version 1.10 book - Part 197 of 212
The Ring programming language version 1.10 book - Part 197 of 212
 
The Ring programming language version 1.10 book - Part 196 of 212
The Ring programming language version 1.10 book - Part 196 of 212The Ring programming language version 1.10 book - Part 196 of 212
The Ring programming language version 1.10 book - Part 196 of 212
 
The Ring programming language version 1.10 book - Part 195 of 212
The Ring programming language version 1.10 book - Part 195 of 212The Ring programming language version 1.10 book - Part 195 of 212
The Ring programming language version 1.10 book - Part 195 of 212
 
The Ring programming language version 1.10 book - Part 194 of 212
The Ring programming language version 1.10 book - Part 194 of 212The Ring programming language version 1.10 book - Part 194 of 212
The Ring programming language version 1.10 book - Part 194 of 212
 
The Ring programming language version 1.10 book - Part 193 of 212
The Ring programming language version 1.10 book - Part 193 of 212The Ring programming language version 1.10 book - Part 193 of 212
The Ring programming language version 1.10 book - Part 193 of 212
 
The Ring programming language version 1.10 book - Part 192 of 212
The Ring programming language version 1.10 book - Part 192 of 212The Ring programming language version 1.10 book - Part 192 of 212
The Ring programming language version 1.10 book - Part 192 of 212
 

The Ring programming language version 1.5.1 book - Part 2 of 180

  • 1. 36.2 MySQL_Init() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237 36.3 MySQL_Error() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237 36.4 MySQL_Connect() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237 36.5 MySQL_Close() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237 36.6 MySQL_Query() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237 36.7 Create Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238 36.8 Create Table and Insert Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238 36.9 MySQL_Insert_ID() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239 36.10 MySQL_Result() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240 36.11 MySQL_Next_Result() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240 36.12 Print Query Result . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240 36.13 MySQL_Columns() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240 36.14 MySQL_Result2() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241 36.15 MySQL_Escape_String() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242 36.16 Save Image inside the database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242 36.17 Restore Image From The Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243 36.18 MySQL_AutoCommit() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243 36.19 MySQL_Commit() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243 36.20 MySQL_Rollback() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243 36.21 Transaction Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243 37 SQLite Functions 245 37.1 sqlite_init() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245 37.2 sqlite_open() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245 37.3 sqlite_execute() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245 37.4 sqlite_close() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245 37.5 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246 38 Security and Internet Functions 248 38.1 MD5() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248 38.2 SHA1() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249 38.3 SHA256() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249 38.4 SHA512() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249 38.5 SHA384() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250 38.6 SHA224() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250 38.7 Encrypt() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250 38.8 Decrypt() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251 38.9 Encryption and Decryption Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251 38.10 File Hash . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251 38.11 Randbytes() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252 38.12 Download() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252 38.13 SendEmail() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252 39 Object Oriented Programming (OOP) 253 39.1 Classes and Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253 39.2 Access Objects Using Braces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255 39.3 Composition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256 39.4 Setter and Getter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257 39.5 Private Attributes and Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257 39.6 Operator Overloading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258 39.7 Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259 39.8 Dynamic Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260 39.9 Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260 39.10 Printing Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261 ix
  • 2. 39.11 Find() and List of Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261 39.12 Sort() and list of objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262 39.13 Using Self.Attribute and Self.Method() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264 39.14 Using This.Attribute and This.Method() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265 40 Functional Programming 266 40.1 Pure Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266 40.2 First-class Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267 40.3 Higher-order Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267 40.4 Anonymous and Nested Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268 40.5 Equality of functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269 41 Reflection and Meta-programming 271 41.1 locals() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271 41.2 globals() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271 41.3 functions() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272 41.4 cfunctions() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272 41.5 islocal() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273 41.6 isglobal() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273 41.7 isfunction() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274 41.8 iscfunction() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274 41.9 packages() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275 41.10 ispackage() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275 41.11 classes() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276 41.12 isclass() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276 41.13 packageclasses() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277 41.14 ispackageclass() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278 41.15 classname() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278 41.16 objectid() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279 41.17 isobject() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279 41.18 attributes() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279 41.19 methods() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279 41.20 isattribute() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280 41.21 isprivateattribute() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280 41.22 ismethod() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281 41.23 isprivatemethod() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281 41.24 addattribute() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282 41.25 addmethod() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282 41.26 getattribute() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284 41.27 setattribute() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285 41.28 mergemethods() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286 41.29 packagename() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287 42 Stdlib Functions 288 42.1 puts() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288 42.2 print() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288 42.3 Print2Str() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288 42.4 getstring() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289 42.5 getnumber() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289 42.6 apppath() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289 42.7 justfilepath() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289 42.8 justfilename() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290 42.9 value() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290 42.10 times() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290 x
  • 3. 42.11 map() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291 42.12 filter() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291 42.13 split() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291 42.14 splitmany() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292 42.15 newlist() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292 42.16 capitalized() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292 42.17 isspecial() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293 42.18 isvowel() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293 42.19 linecount() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293 42.20 factorial() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293 42.21 fibonacci() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294 42.22 isprime() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294 42.23 sign() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294 42.24 list2file() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295 42.25 file2list() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295 42.26 startswith() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295 42.27 endswith() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295 42.28 gcd() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296 42.29 lcm() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296 42.30 sumlist() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296 42.31 prodlist() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297 42.32 evenorodd() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297 42.33 factors() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297 42.34 palindrome() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298 42.35 isleapyear() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298 42.36 binarydigits() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298 42.37 matrixmulti() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299 42.38 matrixtrans() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299 42.39 dayofweek() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299 42.40 permutation() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300 42.41 readline() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300 42.42 substring() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300 42.43 changestring() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301 42.44 sleep() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301 42.45 ismainsourcefile() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301 42.46 direxists() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302 42.47 makedir() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302 42.48 fsize() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302 42.49 trimall() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302 42.50 trimleft() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303 42.51 trimright() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303 42.52 epochtime() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303 42.53 SystemCmd() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303 42.54 ListAllFiles() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303 43 Stdlib Classes 305 43.1 StdBase Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305 43.2 String Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306 43.3 List Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 308 43.4 Stack Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310 43.5 Queue Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310 43.6 HashTable Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311 43.7 Tree Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312 43.8 Math Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313 xi
  • 4. 43.9 DateTime Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317 43.10 File Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 318 43.11 System Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319 43.12 Debug Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320 43.13 DataType Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321 43.14 Conversion Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322 43.15 ODBC Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323 43.16 MySQL Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324 43.17 SQLite Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325 43.18 Security Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 326 43.19 Internet Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327 44 Declarative Programming using Nested Structures 328 44.1 Creating Objects inside Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328 44.2 Composition and Returning Objects and Lists by Reference . . . . . . . . . . . . . . . . . . . . . . 329 44.3 Executing code after the end of object access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331 44.4 Declarative Programming on the top of Object-Oriented . . . . . . . . . . . . . . . . . . . . . . . . 331 44.5 More beautiful Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332 45 Natural Language Programming 334 45.1 History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334 45.2 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334 45.3 Change the Ring Keyword ‘And’ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335 45.4 Change the Ring Operator ‘+’ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336 45.5 Change the ‘=’ operator to ‘is’ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337 45.6 Using Eval() with our Natural Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 338 45.7 BraceStart and BraceEnd Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 339 45.8 BraceExprEval Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 340 45.9 Real Natural Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 340 45.10 BraceError() Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341 45.11 Clean Natural Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 342 46 Using the Natural Library 344 46.1 Natural Library - Demo Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 344 46.2 Defining Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346 46.3 Natural Library - Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349 46.4 Defining commands using classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349 47 Web Development (CGI Library) 351 47.1 Configure the Apache web server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351 47.2 Ring CGI Hello World Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352 47.3 Hello World Program using the Web Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352 47.4 Web Library Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353 47.5 HTTP Get Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353 47.6 HTTP POST Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 358 47.7 Upload Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360 47.8 Cookies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 363 47.9 URL Encode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365 47.10 Templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 366 47.11 HTML Special Characters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 368 47.12 Hash Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369 47.13 Random Image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371 47.14 HTML Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 372 47.15 HTML Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 374 47.16 Gradient . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375 xii
  • 5. 47.17 Generating Pages using Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 376 47.18 HtmlPage Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 380 47.19 Using Bootstrap Library using Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381 47.20 Using Bootstrap Library using Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 382 47.21 CRUD Example using MVC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385 47.22 Users registration and Login . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 387 47.23 Database, ModelBase & ControllerBase classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393 47.24 WebLib API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 398 47.25 Application Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400 47.26 Page Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400 47.27 ScriptFunctions Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 402 47.28 StyleFunctions Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403 47.29 WebPage Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403 47.30 HtmlPage Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 404 48 Using RingLibCurl 405 48.1 Get Request . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 405 48.2 Post Request . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 405 48.3 Facebook Login . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 405 48.4 Save Output to String . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 406 48.5 Get Stock Data From Yahoo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 407 49 Using RingZip 409 49.1 Create Zip File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 409 49.2 Extract Zip File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 409 49.3 Print Files in Zip file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 409 49.4 Using RingZip Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 409 49.5 Zip Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 411 49.6 ZipEntry Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 411 50 Graphics and 2D Games programming using RingAllegro 412 50.1 Drawing, Animation and Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 412 50.2 Using TrueType Fonts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 418 50.3 Playing Sound Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 419 50.4 Scaling and Rotating Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 420 50.5 Display Transparent Image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 421 50.6 Using Threads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 422 51 Using RingLibSDL 425 51.1 Create Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425 51.2 Display Image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425 51.3 Switch between two images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 426 51.4 Draw Rectangle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 426 51.5 Display PNG Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427 51.6 Use TTF Fonts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427 51.7 Display Transparent Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427 51.8 Close Window Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 428 51.9 Mouse Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429 51.10 Play Sound . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 430 52 Demo Project - Game Engine for 2D Games 432 52.1 Project Layers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 432 52.2 Graphics Library bindings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 432 52.3 Interface to graphics library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433 52.4 Game Engine Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433 xiii
  • 6. 52.5 Games Layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433 52.6 Game Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 434 52.7 GameObject Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 434 52.8 Sprite Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 435 52.9 Text Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 435 52.10 Animate Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 436 52.11 Sound Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 436 52.12 Map Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 436 52.13 Using the Game Engine - Creating the Game Window . . . . . . . . . . . . . . . . . . . . . . . . . 437 52.14 Using the Game Engine - Drawing Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 437 52.15 Using the Game Engine - Moving Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 438 52.16 Using the Game Engine - Playing Sound . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 440 52.17 Using the Game Engine - Animation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 441 52.18 Using the Game Engine - Animation and Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . 442 52.19 Using the Game Engine - Sprite - Automatic Movement using Keyboard . . . . . . . . . . . . . . . 444 52.20 Using the Game Engine - Sprite - Keypress event . . . . . . . . . . . . . . . . . . . . . . . . . . . . 445 52.21 Using the Game Engine - Sprite - Mouse event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 445 52.22 Using the Game Engine - Sprite - State event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 446 52.23 Using the Game Engine - Animate - Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 447 52.24 Using the Game Engine - Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 449 52.25 Using the Game Engine - Map Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 451 52.26 Using the Game Engine - Object and Drawing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 452 52.27 Stars Fighter Game . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 455 52.28 Flappy Bird 3000 Game . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 463 52.29 Super Man 2016 Game . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 470 53 Building Games For Android 482 53.1 Download Requirements and Update the Android SDK . . . . . . . . . . . . . . . . . . . . . . . . . 482 53.2 Project Folder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 482 53.3 Building the project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 483 54 Using RingOpenGL and RingFreeGLUT for 3D Graphics 485 54.1 Samples Source (Authors) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 485 54.2 What is RingOpenGL? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 485 54.3 What is RingFreeGLUT? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 486 54.4 The First Window using RingFreeGLUT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 486 54.5 Drawing using RingOpenGL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 487 54.6 The First Triangle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 489 54.7 Window Resize Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 490 54.8 Triangle Rotation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 491 54.9 Keyboard Events and Colors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 492 54.10 The Camera . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 495 54.11 Mouse Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 502 54.12 Menu Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 505 54.13 Using Fonts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 512 54.14 Frames Per Second . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 520 54.15 Make a Cube using RingOpenGL and RingFreeGLUT . . . . . . . . . . . . . . . . . . . . . . . . . 529 55 Desktop and Mobile development using RingQt 533 55.1 The First GUI Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 533 55.2 Using Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 535 55.3 Using the QTextEdit Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 536 55.4 Using the QListWidget Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 537 55.5 Using QTreeView and QFileSystemModel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 540 xiv
  • 7. 55.6 Using QTreeWidget and QTreeWidgetItem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 541 55.7 Using QComboBox Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 542 55.8 Creating Menubar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 543 55.9 Creating Toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 546 55.10 Creating StatusBar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 547 55.11 Using QDockWidget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 548 55.12 Using QTabWidget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 550 55.13 Using QTableWidget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 551 55.14 Using QProgressBar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 552 55.15 Using QSpinBox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 553 55.16 Using QSlider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 554 55.17 Using QDateEdit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 555 55.18 Using QDial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 556 55.19 Using QWebView . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 559 55.20 Using QCheckBox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 560 55.21 Using QRadioButton and QButtonGroup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 561 55.22 Adding Hyperlink to QLabel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 563 55.23 QVideoWidget and QMediaPlayer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 564 55.24 Using QFrame . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 566 55.25 Display Image using QLabel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 567 55.26 Menubar and StyleSheet Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 568 55.27 QLineEdit Events and QMessageBox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 570 55.28 Other Widgets Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 572 55.29 Using the QTimer Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 574 55.30 Using QProgressBar and Timer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 575 55.31 Display Scaled Image using QLabel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 576 55.32 Using the QFileDialog Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 577 55.33 Drawing using QPainter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 578 55.34 Printing using QPrinter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 580 55.35 Creating More than one Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 581 55.36 Playing Sound . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 582 55.37 Using the QColorDialog Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 582 55.38 Using qLCDNumber Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 584 55.39 Movable Label Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 584 55.40 QMessagebox Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 585 55.41 Using QInputDialog Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 586 55.42 Dialog Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 588 55.43 KeyPress and Mouse Move Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 589 55.44 Moving Objects using the Mouse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 590 55.45 Inheritance from GUI Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 594 55.46 Using QDesktopWidget Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 595 55.47 Rotate Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 596 55.48 Change Focus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 598 55.49 Regular Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 599 55.50 Simple Client and Server Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 600 55.51 Dynamic Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 602 55.52 Weight History Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 603 55.53 Notepad Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 607 55.54 The Cards Game . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 622 55.55 Classes and their Methods to use the default events . . . . . . . . . . . . . . . . . . . . . . . . . . . 628 55.56 Methods to use Events with Events Filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 631 55.57 The Difference between Qt and RingQt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 632 55.58 RingQt Classes and their Qt Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 633 55.59 New Classes names - Index Start from 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 633 xv
  • 8. 55.60 Creating Reports using the WebLib and the GUILib . . . . . . . . . . . . . . . . . . . . . . . . . . 634 56 Building RingQt Applications for Mobile 637 56.1 Download Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 637 56.2 Update the Android SDK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 637 56.3 Install Qt for Android . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 637 56.4 Comments about developing for Android using RingQt . . . . . . . . . . . . . . . . . . . . . . . . . 638 57 Objects Library for RingQt Application 640 57.1 Library Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 640 57.2 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 640 57.3 Open_WindowAndLink() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 643 57.4 Open_WindowInPackages() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 644 57.5 Objects Library Source Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 644 58 Using the Form Designer 645 58.1 The Designer Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 646 58.2 The Toolbox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 646 58.3 The Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 646 58.4 Running Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 647 58.5 Events Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 647 58.6 Keyboard Shortcuts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 650 58.7 Menubar Designer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 650 58.8 Window Flags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 651 58.9 Entering Items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 652 58.10 Using Layouts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 652 58.11 More Samples and Tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 652 59 Scope Rules for Variables and Attributes 653 59.1 Three Scopes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 653 59.2 Defining Variables and Variables Access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 653 59.3 How Ring find the variable? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 654 59.4 Using Object.Attribute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 654 59.5 The Self Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 654 59.6 How Ring Define Variables and Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 655 59.7 Conflict between Global Variables and Class Attributes . . . . . . . . . . . . . . . . . . . . . . . . . 655 59.8 Conflict between Class Attributes and Local Variables . . . . . . . . . . . . . . . . . . . . . . . . . 656 59.9 Using Braces to access objects inside Class Methods . . . . . . . . . . . . . . . . . . . . . . . . . . 657 59.10 Accessing the class attributes from braces inside class methods . . . . . . . . . . . . . . . . . . . . 660 59.11 Creating a Class for each Window in GUI applications . . . . . . . . . . . . . . . . . . . . . . . . . 661 59.12 Conflict between self inside braces and self in the class region . . . . . . . . . . . . . . . . . . . . . 662 59.13 Using braces to escape from the current object scope . . . . . . . . . . . . . . . . . . . . . . . . . . 665 59.14 Summary of Scope Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 666 60 Scope Rules for Functions and Methods 668 60.1 How Ring find the Functions and Methods? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 668 60.2 Example about Sharing Names between Functions and Methods . . . . . . . . . . . . . . . . . . . . 669 60.3 Calling a function sharing the name with a method in the current class . . . . . . . . . . . . . . . . . 670 61 Syntax Flexibility 672 61.1 Change Language Keywords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 672 61.2 Change Language Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 673 61.3 Load Syntax Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 674 61.4 Using “()” around the function parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 675 61.5 Using Semi-colon after and between statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 675 xvi
  • 9. 61.6 Using $ and @ in the start of the variable name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 676 61.7 Using the ‘elseif’ keyword as ‘but’ in if statement . . . . . . . . . . . . . . . . . . . . . . . . . . . 676 61.8 Using the ‘else’ keyword as ‘other’ in switch statement . . . . . . . . . . . . . . . . . . . . . . . . . 677 61.9 Using the ‘end’ keyword in different control structures . . . . . . . . . . . . . . . . . . . . . . . . . 677 61.10 Using braces to start and end different control structures . . . . . . . . . . . . . . . . . . . . . . . . 678 61.11 Using ‘put’ and ‘get’ as ‘see’ and ‘give’ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 679 61.12 Using ‘case’ as ‘on’ in switch statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 679 61.13 Using ‘def’ as ‘func’ in functions/methods definition . . . . . . . . . . . . . . . . . . . . . . . . . . 680 61.14 Using braces { } in Packages/Classes/Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 680 61.15 Using ‘end’ keyword after Packages/Classes/Functions . . . . . . . . . . . . . . . . . . . . . . . . . 680 61.16 Using ‘endpackage’/’endclass’/’endfunc’ keywords after Packages/Classes/Functions . . . . . . . . 681 62 Introduction to the Type Hints Library 682 62.1 Why Type Hints? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 682 62.2 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 682 62.3 User Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 682 62.4 Using Types inside Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 683 62.5 Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 683 63 Distributing Ring Applications 685 63.1 Distributing Applications for Microsoft Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . 685 63.2 Protecting the Source Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 685 63.3 Creating Windows Installer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 686 63.4 Using C/C++ Compiler and Linker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 686 63.5 Distributing Applications and Games for Mobile . . . . . . . . . . . . . . . . . . . . . . . . . . . . 686 64 Command Line Options 687 64.1 Printing Tokens . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 687 64.2 Printing Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 689 64.3 Printing Intermediate Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 693 64.4 Printing Final Intermediate Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 696 64.5 CGI Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 700 64.6 No Run . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 700 64.7 Printing Instruction Operation Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 700 64.8 Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 700 64.9 Generate Object File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 701 65 Low Level Functions 702 65.1 callgc() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 703 65.2 varptr() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 703 65.3 space() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 703 65.4 nullpointer() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 704 65.5 object2pointer() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 704 65.6 pointer2object() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 704 65.7 ptrcmp() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 705 65.8 ringvm_cfunctionslist() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 706 65.9 ringvm_functionslist() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 706 65.10 ringvm_classeslist() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 707 65.11 ringvm_packageslist() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 707 65.12 ringvm_memorylist() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 708 65.13 ringvm_calllist() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 710 65.14 ringvm_fileslist() function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 711 65.15 ringvm_settrace() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 712 65.16 ringvm_tracedata() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 712 65.17 ringvm_traceevent() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 712 xvii
  • 10. 65.18 ringvm_tracefunc() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 713 65.19 ringvm_scopescount() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 713 65.20 ringvm_evalinscope() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 713 65.21 ringvm_passerror() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 713 65.22 ringvm_hideerrormsg() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 713 65.23 ringvm_callfunc() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 714 65.24 Example - Using the Trace Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 714 65.25 Example - The Trace Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 718 66 The Trace Library and the Interactive Debugger 722 66.1 Loading the Trace library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 722 66.2 Trace All Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 722 66.3 Trace control flow between functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 722 66.4 Pass Error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 723 66.5 Interactive Debugger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 723 66.6 Execute Program Line by Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 723 66.7 BreakPoint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 724 66.8 Disable BreakPoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 724 66.9 Using the Interactive Debugger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 724 67 Embedding Ring in Ring 727 67.1 Embedding Ring in Ring without sharing the State . . . . . . . . . . . . . . . . . . . . . . . . . . . 727 67.2 Serial Execution of Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 728 68 Extension using the C/C++ languages 729 68.1 ring_ext.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 729 68.2 ring_ext.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 729 68.3 Module Organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 730 68.4 Function Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 731 68.5 Check Parameters Count . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 731 68.6 Display Error Message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 732 68.7 Check Parameters Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 732 68.8 Get Parameters Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 732 68.9 Return Value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 733 68.10 Function Prototype . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 733 68.11 Sin() Function Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 733 68.12 Fopen() and Fclose() Functions Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 733 68.13 Ring API - List Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 734 68.14 Ring API - String Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 736 68.15 MySQL_Columns() Function Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 736 68.16 Dynamic/Shared Libraries (DLL/So) and LoadLib() function . . . . . . . . . . . . . . . . . . . . . 737 69 Embedding Ring Language in C/C++ Programs 739 69.1 Ring State . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 739 69.2 Ring State Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 739 69.3 Ring State Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 740 70 Code Generator for wrapping C/C++ Libraries 742 70.1 Using the tool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 742 70.2 Configuration file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 742 70.3 Using the function prototype . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 742 70.4 Adding code to the generated code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 744 70.5 Prefix for Functions Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 744 70.6 Generate function to wrap structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 744 70.7 Determine Structure Members Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 745 xviii