SlideShare a Scribd company logo
Ring Documentation, Release 1.3
RING_API void ringlib_init(RingState *pRingState)
{
ring_vm_funcregister("dlfunc",ring_ringlib_dlfunc);
}
Then from Ring you can load the DLL file using LoadLib() function then call the C function that called dlfunc() as
any Ring function.
See "Dynamic DLL" + NL
LoadLib("ringlib.dll")
dlfunc()
Output
Dynamic DLL
Message from dlfunc
When you read the documentation you will know about how to get parameters like (strings, numbers, lists and objects)
And how to return a value (any type) from you function.
From experience, when we support a C library or C++ Library
We discovered that a lot of functions share a lot of code
To save our time, and to quickly generate wrappers for C/C++ Libraries to be used in Ring
We have this code generator
https://github.com/ring-lang/ring/blob/master/extensions/codegen/parsec.ring
The code generator is just a Ring program < 1200 lines of Ring code
The generator take as input a configuration file contains the C/C++ library information
like Functions Prototype, Classes and Methods, Constants, Enum, Structures and members , etc.
Then the generator will generate
*.C File for C libraries (to be able to use the library functions)
*.CPP File for C++ libraries (to be able to use C++ classes and methods)
*.Ring File (to be able to use C++ classes as Ring classes)
*.RH file (Constants)
To understand how the generator work check this extension for the Allegro game programming library
https://github.com/ring-lang/ring/tree/master/extensions/ringallegro
At first we have the configuration file
https://github.com/ring-lang/ring/blob/master/extensions/ringallegro/allegro.cf
To write this file, i just used the Allegro documentation + the Ring code generator rules
Then after executing the generator using this batch file
https://github.com/ring-lang/ring/blob/master/extensions/ringallegro/gencode.bat
or using this script
https://github.com/ring-lang/ring/blob/master/extensions/ringallegro/gencode.sh
I get the generated source code file
https://github.com/ring-lang/ring/blob/master/extensions/ringallegro/ring_allegro.c
68.48. How to extend RingQt and add more classes? 808
Ring Documentation, Release 1.3
The generated source code file (ring_allegro.c) is around 12,000 Lines of code (12 KLOC)
While the configuration file is less than 1 KLOC
To build the library (create the DLL files)
https://github.com/ring-lang/ring/blob/master/extensions/ringallegro/buildvc.bat
Also you can check this extension for the LibSDL Library
https://github.com/ring-lang/ring/tree/master/extensions/ringsdl
After this know you should know about
1 - Writing the configuration file
2 - Using the Code Generator
3 - Building your library/extension
4 - Using your library/extension from Ring code
Let us move now to you question about Qt
We have RingQt which is just an extension to ring (ringqt.dll)
You don’t need to modify Ring.
1. You just need to modify RingQt
2. Or extend Ring with another extension based on Qt (but the same Qt version)
For the first option see the RingQt extension
https://github.com/ring-lang/ring/tree/master/extensions/ringqt
Configuration file
https://github.com/ring-lang/ring/blob/master/extensions/ringqt/qt.cf
To generate the source code
https://github.com/ring-lang/ring/blob/master/extensions/ringqt/gencode.bat
https://github.com/ring-lang/ring/blob/master/extensions/ringqt/gencode.sh
https://github.com/ring-lang/ring/blob/master/extensions/ringqt/gencodeandroid.bat
To build the DLL/so/Dylib files
https://github.com/ring-lang/ring/blob/master/extensions/ringqt/buildmingw32.bat
https://github.com/ring-lang/ring/blob/master/extensions/ringqt/buildgcc.sh
https://github.com/ring-lang/ring/blob/master/extensions/ringqt/buildclang.sh
Study RingQt
Learn about the options that you have
1. wrapping a Qt class directly
2. Creating a new class then wrapping your new class
For the second option (in the previous two points or in the two points before that)
You will create new classes in C++ code
Then you merge these classes to RingQt or provide special DLL for them (your decision)
If your work is general (will help others) just put it to RingQt.
68.48. How to extend RingQt and add more classes? 809
Ring Documentation, Release 1.3
if your work is special (to specific application) just put it in another extension.
68.49 How to add Combobox and other elements to the cells of a
QTableWidget?
Check the next code
Load "guilib.ring"
New qApp
{
win1 = new qMainWindow() {
setGeometry(100,100,1100,370)
setwindowtitle("Using QTableWidget")
Table1 = new qTableWidget(win1) {
setrowcount(10) setcolumncount(10)
setGeometry(0,0,800,400)
setselectionbehavior(QAbstractItemView_SelectRows)
for x = 1 to 10
for y = 1 to 10
item1 = new qtablewidgetitem("R"+X+"C"+Y)
setitem(x-1,y-1, item1)
next
next
cmb = new QComboBox(Table1) {
alist = ["one","two","three","four","five"]
for x in aList additem(x,0) next
}
setCellWidget(5, 5, cmb)
}
setcentralwidget(table1)
show()
}
exec()
}
68.50 How to perform some manipulations on selected cells in
QTableWidget?
Check the next sample
Load "guilib.ring"
New qApp {
win1 = new qMainWindow() {
setGeometry(100,100,800,600)
setwindowtitle("Using QTableWidget")
Table1 = new qTableWidget(win1) {
setrowcount(10) setcolumncount(10)
setGeometry(10,10,400,400)
68.49. How to add Combobox and other elements to the cells of a QTableWidget? 810
Ring Documentation, Release 1.3
for x = 1 to 10
for y = 1 to 10
item1 = new qtablewidgetitem("10")
setitem(x-1,y-1,item1)
next
next
}
btn1 = new qPushButton(win1) {
setText("Increase")
setGeometry(510,10,100,30)
setClickEvent("pClick()")
}
show()
}
exec()
}
func pClick
for nRow = 0 to Table1.rowcount() - 1
for nCol = 0 to Table1.columncount() - 1
Table1.item(nRow,nCol) {
if isSelected()
setText( "" + ( 10 + text()) )
ok
}
next
next
68.50. How to perform some manipulations on selected cells in QTableWidget? 811
CHAPTER
SIXTYNINE
LANGUAGE REFERENCE
In this chapter we will learn about
• Language keywords
• Language Functions
• Compiler Errors
• Runtime Errors
• Language Grammar
• Virtual Machine (VM) Instructions
69.1 Language Keywords
Keywords Count : 46
• again
• and
• but
• bye
• call
• case
• catch
• changeringkeyword
• changeringoperator
• class
• def
• do
• done
• else
• elseif
• end
• exit
812
Ring Documentation, Release 1.3
• for
• from
• func
• get
• give
• if
• import
• in
• load
• loadsyntax
• loop
• new
• next
• not
• off
• ok
• on
• or
• other
• package
• private
• put
• return
• see
• step
• switch
• to
• try
• while
69.2 Language Functions
Functions Count : 227
acos() add() addattribute() adddays() addmethod() ascii()
asin() assert()
atan() atan2() attributes() binarysearch() callgc() ceil()
cfunctions() char()
chdir() classes() classname() clearerr() clock() clockspersecond()
69.2. Language Functions 813
Ring Documentation, Release 1.3
closelib() copy()
cos() cosh() currentdir() date() dec() decimals() decrypt() del()
diffdays() dir() download() encrypt() eval() exefilename()
exefolder() exp()
fabs() fclose() feof() ferror() fexists() fflush() fgetc() fgetpos()
fgets() filename() find() floor() fopen() fputc() fputs() fread()
freopen() fseek() fsetpos() ftell() functions() fwrite()
getattribute() getchar()
globals() hex() hex2str() input() insert() intvalue() isalnum() isalpha()
isandroid() isattribute() iscfunction() isclass() iscntrl()
isdigit() isfreebsd() isfunction()
isglobal() isgraph() islinux() islist() islocal()
islower() ismacosx() ismethod()
ismsdos() isnull() isnumber() isobject() ispackage()
ispackageclass() isprint() isprivateattribute()
isprivatemethod() ispunct() isspace() isstring()
isunix() isupper() iswindows() iswindows64()
isxdigit() left() len() lines() list() list2str() loadlib() locals()
log() log10() lower() max() md5() mergemethods() methods() min()
murmur3hash() mysql_autocommit() mysql_close()
mysql_columns() mysql_commit() mysql_connect() mysql_error()
mysql_escape_string()
mysql_info() mysql_init() mysql_insert_id() mysql_next_result()
mysql_query() mysql_result() mysql_result2() mysql_rollback()
nullpointer() number() object2pointer() objectid()
odbc_autocommit() odbc_close() odbc_colcount() odbc_columns()
odbc_commit() odbc_connect() odbc_datasources()
odbc_disconnect() odbc_drivers() odbc_execute() odbc_fetch() odbc_getdata()
odbc_init() odbc_rollback() odbc_tables() packageclasses() packagename()
packages() perror() pointer2object() pow()
prevfilename() ptrcmp() raise() randbytes() random()
read() remove() rename()
reverse() rewind() right()
ring_state_init() ring_state_runcode() ring_state_delete()
ring_state_runfile() ring_state_findvar() ring_state_newvar()
ring_state_runobjectfile() ring_state_main()
ringvm_calllist() ringvm_cfunctionslist() ringvm_classeslist()
ringvm_fileslist() ringvm_functionslist()
ringvm_memorylist() ringvm_packageslist() sendemail()
setattribute() sha1() sha224() sha256() sha384()
sha512() sin() sinh() sort() space() sqlite_close()
sqlite_errmsg() sqlite_execute()
sqlite_init() sqlite_open() sqrt() str2hex() str2list()
strcmp() string() substr() swap()
sysget() system() tan() tanh() tempfile() tempname() time() timelist()
trim() type() ungetc() unsigned() upper() varptr() version() windowsnl()
69.3 Compiler Errors
• Error (C1) : Error in parameters list, expected identifier
• Error (C2) : Error in class name
• Error (C3) : Unclosed control strucutre, ‘ok’ is missing
• Error (C4) : Unclosed control strucutre, ‘end’ is missing
69.3. Compiler Errors 814
Ring Documentation, Release 1.3
• Error (C5) : Unclosed control strucutre, next is missing
• Error (C6) : Error in function name
• Error (C7) : Error in list items
• Error (C8) : Parentheses ‘)’ is missing
• Error (C9) : Brackets ‘]’ is missing
• Error (C10) : Error in parent class name
• Error (C11) : Error in expression operator
• Error (C12) :No class definition
• Error (C13) : Error in variable name
• Error (C14) : Try/Catch miss the Catch keyword!
• Error (C15) : Try/Catch miss the Done keyword!
• Error (C16) : Error in Switch statement expression!
• Error (C17) : Switch statement without OFF
• Error (C18) : Missing closing brace for the block opened!
• Error (C19) : Numeric Overflow!
• Error (C20) : Error in package name
• Error (C21) : Unclosed control strucutre, ‘again’ is missing
• Error (C22) : Function redefinition, function is already defined!
• Error (C23) : Using ‘(‘ after number!
• Error (C24) : The parent class name is identical to the subclass name
• Error (C25) : Trying to access the self reference after the object name”
69.4 Runtime Errors
• Error (R1) : Cann’t divide by zero !
• Error (R2) : Array Access (Index out of range) !
• Error (R3) : Calling Function without definition !
• Error (R4) : Stack Overflow !
• Error (R5) : Can’t access the list item, Object is not list !
• Error (R6) : Variable is required
• Error (R7) : Can’t assign to a string letter more than one character
• Error (R8) : Variable is not a string
• Error (R9) : Using exit command outside loops
• Error (R10) : Using exit command with number outside the range
• Error (R11) : error in class name, class not found!
• Error (R12) : error in property name, property not found!
69.4. Runtime Errors 815
Ring Documentation, Release 1.3
• Error (R13) : Object is required
• Error (R14) : Calling Method without definition !
• Error (R15) : error in parent class name, class not found!
• Error (R16) : Using braces to access unknown object !
• Error (R17) : error, using ‘Super’ without parent class!
• Error (R18) : Numeric Overflow!
• Error (R19) : Calling function with less number of parameters!
• Error (R20) : Calling function with extra number of parameters!
• Error (R21) : Using operator with values of incorrect type
• Error (R22) : Using loop command outside loops
• Error (R23) : Using loop command with number outside the range
• Error (R24) : Using uninitialized variable
• Error (R25) : Error in package name, Package not found!
• Error (R26) : Calling private method from outside the class
• Error (R27) : Using private attribute from outside the class
• Error (R28) : Using bad data type as step value
• Error (R29) : Using bad data type in for loop
• Error (R30) : parent class name is identical to child class name
• Error (R31) : Trying to destory the object using the self reference
• Error (R32) : The CALL command expect a variable contains string!
• Error (R33) : Bad decimals number (correct range >= 0 and <=14) !
• Error (R34) : Variable is required for the assignment operation
• Error (R35) : Can’t create/open the file!
• Error (R36) : The column number is not correct! It’s greater than the number of columns in the list
69.5 Language Grammar
Program —> {statement}
Statement —> ‘package’ <Identifier> { ‘.’ <Identifier> }
Statement —> ‘class’ <Identifier> [ ‘from’|’:’|’<’ <Identifier> ]
Statement —> ‘func’|’def’ <Identifier> [ParaList]
Statement —> ‘import’ <Identifier> { ‘.’ <Identifier> }
Statement —> ‘private’
Statement —> ‘load’ <Literal>
Statement —> ‘loadsyntax’ <Literal>
Statement —> ‘changeringkeyword’ <OldKeyword> <NewKeyword>
69.5. Language Grammar 816
Ring Documentation, Release 1.3
Statement —> ‘changeringoperator’ <OldOperator> <NewOperator>
Statement —> ‘see’|’put’ <Expr>
Statement —> ‘give’|’get’ <Identifier>
Statement —> ‘if’ <Expr> [’{‘] {statement} [ {‘but’|’elseif’ <Expr> {Statement} } ] [’else’ {Statement} ]
‘ok’|’end’|’}’
Statement —> ‘Switch’ <Expr> [’{‘] { ‘on’|’case’ <Expr> {statement} } [’other’ {Statement} ] ‘off’|’end’|’}’
Statement —> ‘for’ <Identifier> ‘=’ <Expr> ‘to’ <Expr> [ ‘step’ <Expr> ] [’{‘] {Statement} ‘next’|’end’|’}’
Statement —> ‘for’ <Identifier> ‘in’ <Expr> [ ‘step’ <Expr> ] [’{‘] {statement} ‘next’|’end’|’}’
Statement —> ‘while’ <Expr> [’{‘] {statement} ‘end’|’}’
Statement —> ‘do’ {statement} ‘again’ <Expr>
Statement —> ‘try’ {statement} [’{‘] ‘catch’ {statement} ‘done’|’end’|’}’
Statement —> ‘return’ <Expr>
Statement —> ‘bye’
Statement —> ‘exit’
Statement —> ‘loop’
Statement —> <Expr>
Statement —> epslion
ParaList —> epslion
ParaList —> [’(‘] <Identifier> [{ ‘,’ <Identifier> }] [’)’]
Expr —> <LogicNot> [{ ‘and’|’or’ <LogicNot> }]
LogicNot –> [’not’] <EqualOrNot>
EqualOrNot –> [ ‘=’|’!=’ ] <Compare>
Compare —> <BitOrXor> [ { ‘<’ | ‘>’ | ‘<=’ | ‘>=’ <BitOrXor> } ]
BitOrXor —> <BitAnd> [ { ‘|’ | ‘^’ <BitAnd> } ]
BitAnd —> <BitShift> [ { ‘&’ <BitShift> } ]
BitShift —> <Arithmetic> [ { ‘<<’ | ‘>>’ <Arithmetic> } ]
Arithmetic —> <Term> [ { ‘+’ | ‘-‘ <Term> } ]
Term —> <Range> [ { ‘*’ | ‘/’ | ‘%’ <Range> } ]
Range —> <Factor> [ ‘:’ <Factor> ]
Factor —> <Identifier> [ {Mixer} ] [ ‘=’ <Expr> ]
Factor —> <Number>
Factor —> <Literal>
Factor —> ‘:’ <Identifier>
Factor —> ‘-‘ <Expr>
Factor —> ‘(‘ <Expr> ‘)’
Factor —> <List>
69.5. Language Grammar 817

More Related Content

PDF
The Ring programming language version 1.10 book - Part 22 of 212
PDF
Wprowadzenie do technologii Big Data / Intro to Big Data Ecosystem
PDF
Start Wrap Episode 11: A New Rope
PDF
Bartosz Milewski, “Re-discovering Monads in C++”
PDF
서버 개발자가 바라 본 Functional Reactive Programming with RxJava - SpringCamp2015
PDF
Wprowadzenie do technologi Big Data i Apache Hadoop
PDF
Kirk Shoop, Reactive programming in C++
PDF
Rainer Grimm, “Functional Programming in C++11”
The Ring programming language version 1.10 book - Part 22 of 212
Wprowadzenie do technologii Big Data / Intro to Big Data Ecosystem
Start Wrap Episode 11: A New Rope
Bartosz Milewski, “Re-discovering Monads in C++”
서버 개발자가 바라 본 Functional Reactive Programming with RxJava - SpringCamp2015
Wprowadzenie do technologi Big Data i Apache Hadoop
Kirk Shoop, Reactive programming in C++
Rainer Grimm, “Functional Programming in C++11”

What's hot (20)

PDF
Extend R with Rcpp!!!
PDF
Dynamic C++ ACCU 2013
PDF
Look Ma, “update DB to HTML5 using C++”, no hands! 
PDF
Building fast interpreters in Rust
PDF
Fertile Ground: The Roots of Clojure
PPTX
Python GC
PDF
Java/Scala Lab: Анатолий Кметюк - Scala SubScript: Алгебра для реактивного пр...
PDF
The Evolution of Async-Programming on .NET Platform (TUP, Full)
ODP
Naïveté vs. Experience
KEY
Code as data as code.
PDF
[Let'Swift 2019] 실용적인 함수형 프로그래밍 워크샵
PDF
Java8 stream
PDF
ES6 - Next Generation Javascript
PDF
响应式编程及框架
PDF
Python Performance 101
PDF
PyCon KR 2019 sprint - RustPython by example
PDF
Pwning in c++ (basic)
PDF
Concurrent applications with free monads and stm
PDF
The Ring programming language version 1.5.4 book - Part 40 of 185
PPT
Python Objects
Extend R with Rcpp!!!
Dynamic C++ ACCU 2013
Look Ma, “update DB to HTML5 using C++”, no hands! 
Building fast interpreters in Rust
Fertile Ground: The Roots of Clojure
Python GC
Java/Scala Lab: Анатолий Кметюк - Scala SubScript: Алгебра для реактивного пр...
The Evolution of Async-Programming on .NET Platform (TUP, Full)
Naïveté vs. Experience
Code as data as code.
[Let'Swift 2019] 실용적인 함수형 프로그래밍 워크샵
Java8 stream
ES6 - Next Generation Javascript
响应式编程及框架
Python Performance 101
PyCon KR 2019 sprint - RustPython by example
Pwning in c++ (basic)
Concurrent applications with free monads and stm
The Ring programming language version 1.5.4 book - Part 40 of 185
Python Objects
Ad

Similar to The Ring programming language version 1.3 book - Part 84 of 88 (20)

PDF
The Ring programming language version 1.10 book - Part 102 of 212
PDF
The Ring programming language version 1.6 book - Part 184 of 189
PDF
The Ring programming language version 1.2 book - Part 80 of 84
PDF
The Ring programming language version 1.7 book - Part 92 of 196
PDF
The Ring programming language version 1.5.3 book - Part 189 of 194
PDF
Refactoring to Macros with Clojure
PDF
The Ring programming language version 1.5.3 book - Part 25 of 184
PDF
The Ring programming language version 1.5.2 book - Part 13 of 181
PDF
The Ring programming language version 1.5.1 book - Part 12 of 180
PDF
The Ring programming language version 1.9 book - Part 90 of 210
PDF
The Ring programming language version 1.5.2 book - Part 10 of 181
PDF
The Ring programming language version 1.3 book - Part 83 of 88
PDF
The Ring programming language version 1.5.2 book - Part 75 of 181
PDF
The Ring programming language version 1.4.1 book - Part 3 of 31
PDF
The Ring programming language version 1.9 book - Part 33 of 210
PDF
The Ring programming language version 1.7 book - Part 30 of 196
PDF
The Ring programming language version 1.5.1 book - Part 74 of 180
PDF
The Ring programming language version 1.5.2 book - Part 78 of 181
PDF
The Ring programming language version 1.5.1 book - Part 44 of 180
PDF
The Ring programming language version 1.8 book - Part 94 of 202
The Ring programming language version 1.10 book - Part 102 of 212
The Ring programming language version 1.6 book - Part 184 of 189
The Ring programming language version 1.2 book - Part 80 of 84
The Ring programming language version 1.7 book - Part 92 of 196
The Ring programming language version 1.5.3 book - Part 189 of 194
Refactoring to Macros with Clojure
The Ring programming language version 1.5.3 book - Part 25 of 184
The Ring programming language version 1.5.2 book - Part 13 of 181
The Ring programming language version 1.5.1 book - Part 12 of 180
The Ring programming language version 1.9 book - Part 90 of 210
The Ring programming language version 1.5.2 book - Part 10 of 181
The Ring programming language version 1.3 book - Part 83 of 88
The Ring programming language version 1.5.2 book - Part 75 of 181
The Ring programming language version 1.4.1 book - Part 3 of 31
The Ring programming language version 1.9 book - Part 33 of 210
The Ring programming language version 1.7 book - Part 30 of 196
The Ring programming language version 1.5.1 book - Part 74 of 180
The Ring programming language version 1.5.2 book - Part 78 of 181
The Ring programming language version 1.5.1 book - Part 44 of 180
The Ring programming language version 1.8 book - Part 94 of 202
Ad

More from Mahmoud Samir Fayed (20)

PDF
The Ring programming language version 1.10 book - Part 212 of 212
PDF
The Ring programming language version 1.10 book - Part 211 of 212
PDF
The Ring programming language version 1.10 book - Part 210 of 212
PDF
The Ring programming language version 1.10 book - Part 208 of 212
PDF
The Ring programming language version 1.10 book - Part 207 of 212
PDF
The Ring programming language version 1.10 book - Part 205 of 212
PDF
The Ring programming language version 1.10 book - Part 206 of 212
PDF
The Ring programming language version 1.10 book - Part 204 of 212
PDF
The Ring programming language version 1.10 book - Part 203 of 212
PDF
The Ring programming language version 1.10 book - Part 202 of 212
PDF
The Ring programming language version 1.10 book - Part 201 of 212
PDF
The Ring programming language version 1.10 book - Part 200 of 212
PDF
The Ring programming language version 1.10 book - Part 199 of 212
PDF
The Ring programming language version 1.10 book - Part 198 of 212
PDF
The Ring programming language version 1.10 book - Part 197 of 212
PDF
The Ring programming language version 1.10 book - Part 196 of 212
PDF
The Ring programming language version 1.10 book - Part 195 of 212
PDF
The Ring programming language version 1.10 book - Part 194 of 212
PDF
The Ring programming language version 1.10 book - Part 193 of 212
PDF
The Ring programming language version 1.10 book - Part 192 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 210 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 205 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 203 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 200 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 197 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 194 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

Recently uploaded (20)

PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Encapsulation theory and applications.pdf
PDF
cuic standard and advanced reporting.pdf
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPT
Teaching material agriculture food technology
PPTX
Programs and apps: productivity, graphics, security and other tools
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
KodekX | Application Modernization Development
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Electronic commerce courselecture one. Pdf
PPTX
sap open course for s4hana steps from ECC to s4
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
Cloud computing and distributed systems.
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Machine learning based COVID-19 study performance prediction
DOCX
The AUB Centre for AI in Media Proposal.docx
Network Security Unit 5.pdf for BCA BBA.
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Reach Out and Touch Someone: Haptics and Empathic Computing
Per capita expenditure prediction using model stacking based on satellite ima...
Encapsulation theory and applications.pdf
cuic standard and advanced reporting.pdf
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Teaching material agriculture food technology
Programs and apps: productivity, graphics, security and other tools
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Mobile App Security Testing_ A Comprehensive Guide.pdf
KodekX | Application Modernization Development
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Electronic commerce courselecture one. Pdf
sap open course for s4hana steps from ECC to s4
Digital-Transformation-Roadmap-for-Companies.pptx
Cloud computing and distributed systems.
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Machine learning based COVID-19 study performance prediction
The AUB Centre for AI in Media Proposal.docx

The Ring programming language version 1.3 book - Part 84 of 88

  • 1. Ring Documentation, Release 1.3 RING_API void ringlib_init(RingState *pRingState) { ring_vm_funcregister("dlfunc",ring_ringlib_dlfunc); } Then from Ring you can load the DLL file using LoadLib() function then call the C function that called dlfunc() as any Ring function. See "Dynamic DLL" + NL LoadLib("ringlib.dll") dlfunc() Output Dynamic DLL Message from dlfunc When you read the documentation you will know about how to get parameters like (strings, numbers, lists and objects) And how to return a value (any type) from you function. From experience, when we support a C library or C++ Library We discovered that a lot of functions share a lot of code To save our time, and to quickly generate wrappers for C/C++ Libraries to be used in Ring We have this code generator https://github.com/ring-lang/ring/blob/master/extensions/codegen/parsec.ring The code generator is just a Ring program < 1200 lines of Ring code The generator take as input a configuration file contains the C/C++ library information like Functions Prototype, Classes and Methods, Constants, Enum, Structures and members , etc. Then the generator will generate *.C File for C libraries (to be able to use the library functions) *.CPP File for C++ libraries (to be able to use C++ classes and methods) *.Ring File (to be able to use C++ classes as Ring classes) *.RH file (Constants) To understand how the generator work check this extension for the Allegro game programming library https://github.com/ring-lang/ring/tree/master/extensions/ringallegro At first we have the configuration file https://github.com/ring-lang/ring/blob/master/extensions/ringallegro/allegro.cf To write this file, i just used the Allegro documentation + the Ring code generator rules Then after executing the generator using this batch file https://github.com/ring-lang/ring/blob/master/extensions/ringallegro/gencode.bat or using this script https://github.com/ring-lang/ring/blob/master/extensions/ringallegro/gencode.sh I get the generated source code file https://github.com/ring-lang/ring/blob/master/extensions/ringallegro/ring_allegro.c 68.48. How to extend RingQt and add more classes? 808
  • 2. Ring Documentation, Release 1.3 The generated source code file (ring_allegro.c) is around 12,000 Lines of code (12 KLOC) While the configuration file is less than 1 KLOC To build the library (create the DLL files) https://github.com/ring-lang/ring/blob/master/extensions/ringallegro/buildvc.bat Also you can check this extension for the LibSDL Library https://github.com/ring-lang/ring/tree/master/extensions/ringsdl After this know you should know about 1 - Writing the configuration file 2 - Using the Code Generator 3 - Building your library/extension 4 - Using your library/extension from Ring code Let us move now to you question about Qt We have RingQt which is just an extension to ring (ringqt.dll) You don’t need to modify Ring. 1. You just need to modify RingQt 2. Or extend Ring with another extension based on Qt (but the same Qt version) For the first option see the RingQt extension https://github.com/ring-lang/ring/tree/master/extensions/ringqt Configuration file https://github.com/ring-lang/ring/blob/master/extensions/ringqt/qt.cf To generate the source code https://github.com/ring-lang/ring/blob/master/extensions/ringqt/gencode.bat https://github.com/ring-lang/ring/blob/master/extensions/ringqt/gencode.sh https://github.com/ring-lang/ring/blob/master/extensions/ringqt/gencodeandroid.bat To build the DLL/so/Dylib files https://github.com/ring-lang/ring/blob/master/extensions/ringqt/buildmingw32.bat https://github.com/ring-lang/ring/blob/master/extensions/ringqt/buildgcc.sh https://github.com/ring-lang/ring/blob/master/extensions/ringqt/buildclang.sh Study RingQt Learn about the options that you have 1. wrapping a Qt class directly 2. Creating a new class then wrapping your new class For the second option (in the previous two points or in the two points before that) You will create new classes in C++ code Then you merge these classes to RingQt or provide special DLL for them (your decision) If your work is general (will help others) just put it to RingQt. 68.48. How to extend RingQt and add more classes? 809
  • 3. Ring Documentation, Release 1.3 if your work is special (to specific application) just put it in another extension. 68.49 How to add Combobox and other elements to the cells of a QTableWidget? Check the next code Load "guilib.ring" New qApp { win1 = new qMainWindow() { setGeometry(100,100,1100,370) setwindowtitle("Using QTableWidget") Table1 = new qTableWidget(win1) { setrowcount(10) setcolumncount(10) setGeometry(0,0,800,400) setselectionbehavior(QAbstractItemView_SelectRows) for x = 1 to 10 for y = 1 to 10 item1 = new qtablewidgetitem("R"+X+"C"+Y) setitem(x-1,y-1, item1) next next cmb = new QComboBox(Table1) { alist = ["one","two","three","four","five"] for x in aList additem(x,0) next } setCellWidget(5, 5, cmb) } setcentralwidget(table1) show() } exec() } 68.50 How to perform some manipulations on selected cells in QTableWidget? Check the next sample Load "guilib.ring" New qApp { win1 = new qMainWindow() { setGeometry(100,100,800,600) setwindowtitle("Using QTableWidget") Table1 = new qTableWidget(win1) { setrowcount(10) setcolumncount(10) setGeometry(10,10,400,400) 68.49. How to add Combobox and other elements to the cells of a QTableWidget? 810
  • 4. Ring Documentation, Release 1.3 for x = 1 to 10 for y = 1 to 10 item1 = new qtablewidgetitem("10") setitem(x-1,y-1,item1) next next } btn1 = new qPushButton(win1) { setText("Increase") setGeometry(510,10,100,30) setClickEvent("pClick()") } show() } exec() } func pClick for nRow = 0 to Table1.rowcount() - 1 for nCol = 0 to Table1.columncount() - 1 Table1.item(nRow,nCol) { if isSelected() setText( "" + ( 10 + text()) ) ok } next next 68.50. How to perform some manipulations on selected cells in QTableWidget? 811
  • 5. CHAPTER SIXTYNINE LANGUAGE REFERENCE In this chapter we will learn about • Language keywords • Language Functions • Compiler Errors • Runtime Errors • Language Grammar • Virtual Machine (VM) Instructions 69.1 Language Keywords Keywords Count : 46 • again • and • but • bye • call • case • catch • changeringkeyword • changeringoperator • class • def • do • done • else • elseif • end • exit 812
  • 6. Ring Documentation, Release 1.3 • for • from • func • get • give • if • import • in • load • loadsyntax • loop • new • next • not • off • ok • on • or • other • package • private • put • return • see • step • switch • to • try • while 69.2 Language Functions Functions Count : 227 acos() add() addattribute() adddays() addmethod() ascii() asin() assert() atan() atan2() attributes() binarysearch() callgc() ceil() cfunctions() char() chdir() classes() classname() clearerr() clock() clockspersecond() 69.2. Language Functions 813
  • 7. Ring Documentation, Release 1.3 closelib() copy() cos() cosh() currentdir() date() dec() decimals() decrypt() del() diffdays() dir() download() encrypt() eval() exefilename() exefolder() exp() fabs() fclose() feof() ferror() fexists() fflush() fgetc() fgetpos() fgets() filename() find() floor() fopen() fputc() fputs() fread() freopen() fseek() fsetpos() ftell() functions() fwrite() getattribute() getchar() globals() hex() hex2str() input() insert() intvalue() isalnum() isalpha() isandroid() isattribute() iscfunction() isclass() iscntrl() isdigit() isfreebsd() isfunction() isglobal() isgraph() islinux() islist() islocal() islower() ismacosx() ismethod() ismsdos() isnull() isnumber() isobject() ispackage() ispackageclass() isprint() isprivateattribute() isprivatemethod() ispunct() isspace() isstring() isunix() isupper() iswindows() iswindows64() isxdigit() left() len() lines() list() list2str() loadlib() locals() log() log10() lower() max() md5() mergemethods() methods() min() murmur3hash() mysql_autocommit() mysql_close() mysql_columns() mysql_commit() mysql_connect() mysql_error() mysql_escape_string() mysql_info() mysql_init() mysql_insert_id() mysql_next_result() mysql_query() mysql_result() mysql_result2() mysql_rollback() nullpointer() number() object2pointer() objectid() odbc_autocommit() odbc_close() odbc_colcount() odbc_columns() odbc_commit() odbc_connect() odbc_datasources() odbc_disconnect() odbc_drivers() odbc_execute() odbc_fetch() odbc_getdata() odbc_init() odbc_rollback() odbc_tables() packageclasses() packagename() packages() perror() pointer2object() pow() prevfilename() ptrcmp() raise() randbytes() random() read() remove() rename() reverse() rewind() right() ring_state_init() ring_state_runcode() ring_state_delete() ring_state_runfile() ring_state_findvar() ring_state_newvar() ring_state_runobjectfile() ring_state_main() ringvm_calllist() ringvm_cfunctionslist() ringvm_classeslist() ringvm_fileslist() ringvm_functionslist() ringvm_memorylist() ringvm_packageslist() sendemail() setattribute() sha1() sha224() sha256() sha384() sha512() sin() sinh() sort() space() sqlite_close() sqlite_errmsg() sqlite_execute() sqlite_init() sqlite_open() sqrt() str2hex() str2list() strcmp() string() substr() swap() sysget() system() tan() tanh() tempfile() tempname() time() timelist() trim() type() ungetc() unsigned() upper() varptr() version() windowsnl() 69.3 Compiler Errors • Error (C1) : Error in parameters list, expected identifier • Error (C2) : Error in class name • Error (C3) : Unclosed control strucutre, ‘ok’ is missing • Error (C4) : Unclosed control strucutre, ‘end’ is missing 69.3. Compiler Errors 814
  • 8. Ring Documentation, Release 1.3 • Error (C5) : Unclosed control strucutre, next is missing • Error (C6) : Error in function name • Error (C7) : Error in list items • Error (C8) : Parentheses ‘)’ is missing • Error (C9) : Brackets ‘]’ is missing • Error (C10) : Error in parent class name • Error (C11) : Error in expression operator • Error (C12) :No class definition • Error (C13) : Error in variable name • Error (C14) : Try/Catch miss the Catch keyword! • Error (C15) : Try/Catch miss the Done keyword! • Error (C16) : Error in Switch statement expression! • Error (C17) : Switch statement without OFF • Error (C18) : Missing closing brace for the block opened! • Error (C19) : Numeric Overflow! • Error (C20) : Error in package name • Error (C21) : Unclosed control strucutre, ‘again’ is missing • Error (C22) : Function redefinition, function is already defined! • Error (C23) : Using ‘(‘ after number! • Error (C24) : The parent class name is identical to the subclass name • Error (C25) : Trying to access the self reference after the object name” 69.4 Runtime Errors • Error (R1) : Cann’t divide by zero ! • Error (R2) : Array Access (Index out of range) ! • Error (R3) : Calling Function without definition ! • Error (R4) : Stack Overflow ! • Error (R5) : Can’t access the list item, Object is not list ! • Error (R6) : Variable is required • Error (R7) : Can’t assign to a string letter more than one character • Error (R8) : Variable is not a string • Error (R9) : Using exit command outside loops • Error (R10) : Using exit command with number outside the range • Error (R11) : error in class name, class not found! • Error (R12) : error in property name, property not found! 69.4. Runtime Errors 815
  • 9. Ring Documentation, Release 1.3 • Error (R13) : Object is required • Error (R14) : Calling Method without definition ! • Error (R15) : error in parent class name, class not found! • Error (R16) : Using braces to access unknown object ! • Error (R17) : error, using ‘Super’ without parent class! • Error (R18) : Numeric Overflow! • Error (R19) : Calling function with less number of parameters! • Error (R20) : Calling function with extra number of parameters! • Error (R21) : Using operator with values of incorrect type • Error (R22) : Using loop command outside loops • Error (R23) : Using loop command with number outside the range • Error (R24) : Using uninitialized variable • Error (R25) : Error in package name, Package not found! • Error (R26) : Calling private method from outside the class • Error (R27) : Using private attribute from outside the class • Error (R28) : Using bad data type as step value • Error (R29) : Using bad data type in for loop • Error (R30) : parent class name is identical to child class name • Error (R31) : Trying to destory the object using the self reference • Error (R32) : The CALL command expect a variable contains string! • Error (R33) : Bad decimals number (correct range >= 0 and <=14) ! • Error (R34) : Variable is required for the assignment operation • Error (R35) : Can’t create/open the file! • Error (R36) : The column number is not correct! It’s greater than the number of columns in the list 69.5 Language Grammar Program —> {statement} Statement —> ‘package’ <Identifier> { ‘.’ <Identifier> } Statement —> ‘class’ <Identifier> [ ‘from’|’:’|’<’ <Identifier> ] Statement —> ‘func’|’def’ <Identifier> [ParaList] Statement —> ‘import’ <Identifier> { ‘.’ <Identifier> } Statement —> ‘private’ Statement —> ‘load’ <Literal> Statement —> ‘loadsyntax’ <Literal> Statement —> ‘changeringkeyword’ <OldKeyword> <NewKeyword> 69.5. Language Grammar 816
  • 10. Ring Documentation, Release 1.3 Statement —> ‘changeringoperator’ <OldOperator> <NewOperator> Statement —> ‘see’|’put’ <Expr> Statement —> ‘give’|’get’ <Identifier> Statement —> ‘if’ <Expr> [’{‘] {statement} [ {‘but’|’elseif’ <Expr> {Statement} } ] [’else’ {Statement} ] ‘ok’|’end’|’}’ Statement —> ‘Switch’ <Expr> [’{‘] { ‘on’|’case’ <Expr> {statement} } [’other’ {Statement} ] ‘off’|’end’|’}’ Statement —> ‘for’ <Identifier> ‘=’ <Expr> ‘to’ <Expr> [ ‘step’ <Expr> ] [’{‘] {Statement} ‘next’|’end’|’}’ Statement —> ‘for’ <Identifier> ‘in’ <Expr> [ ‘step’ <Expr> ] [’{‘] {statement} ‘next’|’end’|’}’ Statement —> ‘while’ <Expr> [’{‘] {statement} ‘end’|’}’ Statement —> ‘do’ {statement} ‘again’ <Expr> Statement —> ‘try’ {statement} [’{‘] ‘catch’ {statement} ‘done’|’end’|’}’ Statement —> ‘return’ <Expr> Statement —> ‘bye’ Statement —> ‘exit’ Statement —> ‘loop’ Statement —> <Expr> Statement —> epslion ParaList —> epslion ParaList —> [’(‘] <Identifier> [{ ‘,’ <Identifier> }] [’)’] Expr —> <LogicNot> [{ ‘and’|’or’ <LogicNot> }] LogicNot –> [’not’] <EqualOrNot> EqualOrNot –> [ ‘=’|’!=’ ] <Compare> Compare —> <BitOrXor> [ { ‘<’ | ‘>’ | ‘<=’ | ‘>=’ <BitOrXor> } ] BitOrXor —> <BitAnd> [ { ‘|’ | ‘^’ <BitAnd> } ] BitAnd —> <BitShift> [ { ‘&’ <BitShift> } ] BitShift —> <Arithmetic> [ { ‘<<’ | ‘>>’ <Arithmetic> } ] Arithmetic —> <Term> [ { ‘+’ | ‘-‘ <Term> } ] Term —> <Range> [ { ‘*’ | ‘/’ | ‘%’ <Range> } ] Range —> <Factor> [ ‘:’ <Factor> ] Factor —> <Identifier> [ {Mixer} ] [ ‘=’ <Expr> ] Factor —> <Number> Factor —> <Literal> Factor —> ‘:’ <Identifier> Factor —> ‘-‘ <Expr> Factor —> ‘(‘ <Expr> ‘)’ Factor —> <List> 69.5. Language Grammar 817