SlideShare a Scribd company logo
Ring Documentation, Release 1.9
ring_gettemp_var
4
00000000
0
0
ccatcherror
1
NULL
0
0
ring_settemp_var
4
00000000
0
0
ring_tempflag_var
2
0
0
0
stdin
3
50512DB8
file
0
0
0
stdout
3
50512DD8
file
0
0
0
stderr
3
50512DF8
file
0
0
0
this
4
00000000
0
0
sysargv
3
B:ringbin/ring
B:/ring/tests/scripts/memorylist.ring
0
0
x
2
10
0
0
y
77.13. ringvm_memorylist() function 869
Ring Documentation, Release 1.9
2
20
0
0
77.14 ringvm_calllist() function
The Function return a list of the functions call list.
Each List Member is a list contains the next items
• Function Type
• Function Name
• Program Counter (PC)
• Stack Pointer (SP)
• Temp. Memory List
• Method or Function Flag
• Caller PC
• FuncExec Flag
• ListStart Flag
• Nested Lists Pointer
• State List
Syntax:
RingVM_CallList() ---> List
Example:
hello()
func hello
test()
func test
mylist = ringvm_calllist()
for t in mylist see t[2] + nl next
Output:
function hello() in file B:/ring/tests/scripts/calllist.ring
called from line 1
function test() in file B:/ring/tests/scripts/calllist.ring
called from line 3
ringvm_calllist
77.15 ringvm_fileslist() function
Function return a list of the Ring Files.
77.14. ringvm_calllist() function 870
Ring Documentation, Release 1.9
Syntax:
RingVM_FilesList() ---> List
Example:
load "stdlib.ring"
see ringvm_fileslist()
Output:
B:/ring/tests/scripts/fileslist.ring
B:ringbinstdlib.ring
eval
stdlib.ring
stdlib.rh
stdclasses.ring
stdfunctions.ring
stdbase.ring
stdstring.ring
stdlist.ring
stdstack.ring
stdqueue.ring
stdmath.ring
stddatetime.ring
stdfile.ring
stdsystem.ring
stddebug.ring
stddatatype.ring
stdconversion.ring
stdodbc.ring
stdmysql.ring
stdsecurity.ring
stdinternet.ring
stdhashtable.ring
stdtree.ring
77.16 ringvm_settrace()
The function ringvm_settrace() determine the Trace function name
The trace function is a Ring function that will be called for each event
Syntax:
RingVM_SetTrace(cCode)
77.17 ringvm_tracedata()
Inside the function that we will use for tracing events
We can use the ringvm_tracedata() function to get the event data.
The event data is a list contains the next items
• The Source Code Line Number
77.16. ringvm_settrace() 871
Ring Documentation, Release 1.9
• The Source File Name
• The Function/Method Name
• Method or Function (Bool : True=Method, False=Function/File)
Syntax:
RingVM_TraceData() ---> aDataList
77.18 ringvm_traceevent()
Inside the function that we will use for tracing events
We can use ringvm_traceevent() to know the event type
• New Line
• Before Function
• After Function
• Runtime Error
• Before C Function
• After C Function
Syntax:
RingVM_TraceEvent() ---> nTraceEvent
77.19 ringvm_tracefunc()
The function return the name of the function that we are using for tracing events.
Syntax:
RingVM_TraceEvent() ---> cCode
77.20 ringvm_scopescount()
We can use the RingVM_ScopesCount() function to know the number of scopes used in the application.
In the start of the program, We have the (global scope only)
When we call a function, A new scope is created.
When the function execution is done, the function scope is deleted.
Syntax:
RingVM_ScopesCount() ---> nScopes
77.18. ringvm_traceevent() 872
Ring Documentation, Release 1.9
77.21 ringvm_evalinscope()
The function ringvm_evalinscope() is similar to the eval() function
Unlike eval() which execute the code in the current scope
Using RingVM_EvalInScope() we can execute the scope in a specific scope.
Syntax:
RingVM_EvalInScope(nScope,cCode)
77.22 ringvm_passerror()
When we have runtime error, After printing the Error message, Ring will end the execution of the program.
Using ringvm_passerror() we can avoid that, and continue the execution of our program.
Syntax:
RingVM_PassError()
77.23 ringvm_hideerrormsg()
We can disable/enable displaying the runtime error messages using the RingVM_HideErrorMsg() function.
Syntax:
RingVM_HideErrorMsg(lStatus)
77.24 ringvm_callfunc()
We can call a function from a string without using eval() using the ringvm_callfunc()
Syntax:
RingVM_CallFunc(cFuncName)
77.25 Example - Using the Trace Functions
The next example use the Trace Functions to trace the program Events!
In practical, We will use the Trace Library instead of these low level functions!
load "tracelib.ring"
ringvm_settrace("mytrace()")
see "Hello, world!" + nl
see "Welcome" + nl
see "How are you?" +nl
mytest()
77.21. ringvm_evalinscope() 873
Ring Documentation, Release 1.9
new myclass { mymethod() }
func mytest
see "Message from mytest" + nl
func mytrace
see "====== The Trace function is Active ======" + nl +
"Trace Function Name : " + ringvm_TraceFunc() + nl +
"Trace Event : "
switch ringvm_TraceEvent()
on TRACEEVENT_NEWLINE see "New Line"
on TRACEEVENT_NEWFUNC see "New Function"
on TRACEEVENT_RETURN see "Return"
on TRACEEVENT_ERROR see "Error"
on TRACEEVENT_BEFORECFUNC see "Before C Function"
on TRACEEVENT_AFTERCFUNC see "After C Function"
off
see nl +
"Line Number : " + ringvm_tracedata()[TRACEDATA_LINENUMBER] + nl +
"File Name : " + ringvm_tracedata()[TRACEDATA_FILENAME] + nl +
"Function Name : " + ringvm_tracedata()[TRACEDATA_FUNCNAME] + nl +
"Method or Function : "
if ringvm_tracedata()[TRACEDATA_METHODORFUNC] =
TRACEDATA_METHODORFUNC_METHOD
see "Method"
else
if ringvm_tracedata()[TRACEDATA_FUNCNAME] = NULL
see "Command"
else
see "Function"
ok
ok
see nl + Copy("=",42) + nl
class myclass
func mymethod
see "Message from mymethod" + nl
Output:
====== The Trace function is Active ======
Trace Function Name : mytrace()
Trace Event : After C Function
Line Number : 3
File Name : test1.ring
Function Name : ringvm_settrace
Method or Function : Function
==========================================
====== The Trace function is Active ======
Trace Function Name : mytrace()
Trace Event : New Line
Line Number : 5
File Name : test1.ring
Function Name :
Method or Function : Command
==========================================
Hello, world!
====== The Trace function is Active ======
77.25. Example - Using the Trace Functions 874
Ring Documentation, Release 1.9
Trace Function Name : mytrace()
Trace Event : New Line
Line Number : 6
File Name : test1.ring
Function Name :
Method or Function : Command
==========================================
Welcome
====== The Trace function is Active ======
Trace Function Name : mytrace()
Trace Event : New Line
Line Number : 7
File Name : test1.ring
Function Name :
Method or Function : Command
==========================================
How are you?
====== The Trace function is Active ======
Trace Function Name : mytrace()
Trace Event : New Line
Line Number : 8
File Name : test1.ring
Function Name :
Method or Function : Command
==========================================
====== The Trace function is Active ======
Trace Function Name : mytrace()
Trace Event : New Function
Line Number : 8
File Name : test1.ring
Function Name : mytest
Method or Function : Function
==========================================
====== The Trace function is Active ======
Trace Function Name : mytrace()
Trace Event : New Line
Line Number : 12
File Name : test1.ring
Function Name : mytest
Method or Function : Function
==========================================
Message from mytest
====== The Trace function is Active ======
Trace Function Name : mytrace()
Trace Event : New Line
Line Number : 14
File Name : test1.ring
Function Name : mytest
Method or Function : Function
==========================================
====== The Trace function is Active ======
Trace Function Name : mytrace()
Trace Event : Return
Line Number : 8
File Name : test1.ring
Function Name :
Method or Function : Command
==========================================
77.25. Example - Using the Trace Functions 875
Ring Documentation, Release 1.9
====== The Trace function is Active ======
Trace Function Name : mytrace()
Trace Event : New Line
Line Number : 9
File Name : test1.ring
Function Name :
Method or Function : Command
==========================================
====== The Trace function is Active ======
Trace Function Name : mytrace()
Trace Event : New Line
Line Number : 43
File Name : test1.ring
Function Name :
Method or Function : Command
==========================================
====== The Trace function is Active ======
Trace Function Name : mytrace()
Trace Event : Before C Function
Line Number : 9
File Name : test1.ring
Function Name : ismethod
Method or Function : Function
==========================================
====== The Trace function is Active ======
Trace Function Name : mytrace()
Trace Event : After C Function
Line Number : 9
File Name : test1.ring
Function Name : ismethod
Method or Function : Function
==========================================
====== The Trace function is Active ======
Trace Function Name : mytrace()
Trace Event : New Function
Line Number : 9
File Name : test1.ring
Function Name : mymethod
Method or Function : Method
==========================================
====== The Trace function is Active ======
Trace Function Name : mytrace()
Trace Event : New Line
Line Number : 44
File Name : test1.ring
Function Name : mymethod
Method or Function : Method
==========================================
Message from mymethod
====== The Trace function is Active ======
Trace Function Name : mytrace()
Trace Event : Return
Line Number : 9
File Name : test1.ring
Function Name :
Method or Function : Command
==========================================
====== The Trace function is Active ======
77.25. Example - Using the Trace Functions 876
Ring Documentation, Release 1.9
Trace Function Name : mytrace()
Trace Event : Before C Function
Line Number : 9
File Name : test1.ring
Function Name : ismethod
Method or Function : Function
==========================================
====== The Trace function is Active ======
Trace Function Name : mytrace()
Trace Event : After C Function
Line Number : 9
File Name : test1.ring
Function Name : ismethod
Method or Function : Function
==========================================
====== The Trace function is Active ======
Trace Function Name : mytrace()
Trace Event : Before C Function
Line Number : 9
File Name : test1.ring
Function Name : ismethod
Method or Function : Function
==========================================
====== The Trace function is Active ======
Trace Function Name : mytrace()
Trace Event : After C Function
Line Number : 9
File Name : test1.ring
Function Name : ismethod
Method or Function : Function
==========================================
====== The Trace function is Active ======
Trace Function Name : mytrace()
Trace Event : New Line
Line Number : 11
File Name : test1.ring
Function Name :
Method or Function : Command
==========================================
77.26 Example - The Trace Library
The next example uses the Trace functions provided by the Ring language to create the Trace library.
Using the Trace library we have nice Tracing tools and Interaction debugger too.
# Trace Events
TRACEEVENT_NEWLINE = 1
TRACEEVENT_NEWFUNC = 2
TRACEEVENT_RETURN = 3
TRACEEVENT_ERROR = 4
TRACEEVENT_BEFORECFUNC = 5
TRACEEVENT_AFTERCFUNC = 6
# Trace Data
TRACEDATA_LINENUMBER = 1
77.26. Example - The Trace Library 877
Ring Documentation, Release 1.9
TRACEDATA_FILENAME = 2
TRACEDATA_FUNCNAME = 3
TRACEDATA_METHODORFUNC = 4
# Method of Function
TRACEDATA_METHODORFUNC_METHOD = TRUE
TRACEDATA_METHODORFUNC_NOTMETHOD = FALSE
TRACE_BREAKPOINTS = TRUE
TRACE_TEMPLIST = []
func Trace cType
switch trim(lower(cType))
on :AllEvents
ringvm_settrace("TraceLib_AllEvents()")
on :Functions
ringvm_settrace("TraceLib_Functions()")
on :PassError
ringvm_settrace("TraceLib_PassError()")
on :Debugger
ringvm_settrace("TraceLib_Debugger()")
on :LineByLine
ringvm_settrace("TraceLib_LineByLine()")
off
func TraceLib_AllEvents
if right(ringvm_tracedata()[TRACEDATA_FILENAME],13) = "tracelib.ring"
return
ok
see "====== The Trace function is Active ======" + nl +
"Trace Function Name : " + ringvm_TraceFunc() + nl +
"Trace Event : "
switch ringvm_TraceEvent()
on TRACEEVENT_NEWLINE see "New Line"
on TRACEEVENT_NEWFUNC see "New Function"
on TRACEEVENT_RETURN see "Return"
on TRACEEVENT_ERROR see "Error"
on TRACEEVENT_BEFORECFUNC see "Before C Function"
on TRACEEVENT_AFTERCFUNC see "After C Function"
off
see nl +
"Line Number : " + ringvm_tracedata()[TRACEDATA_LINENUMBER] + nl +
"File Name : " + ringvm_tracedata()[TRACEDATA_FILENAME] + nl +
"Function Name : " + ringvm_tracedata()[TRACEDATA_FUNCNAME] + nl +
"Method or Function : "
if ringvm_tracedata()[TRACEDATA_METHODORFUNC] =
TRACEDATA_METHODORFUNC_METHOD
see "Method"
else
if ringvm_tracedata()[TRACEDATA_FUNCNAME] = NULL
see "Command"
else
see "Function"
ok
ok
see nl + Copy("=",42) + nl
77.26. Example - The Trace Library 878

More Related Content

PDF
The Ring programming language version 1.5.3 book - Part 88 of 184
PDF
The Ring programming language version 1.5.4 book - Part 78 of 185
PDF
The Ring programming language version 1.5.1 book - Part 75 of 180
PDF
The Ring programming language version 1.8 book - Part 87 of 202
PDF
The Ring programming language version 1.7 book - Part 84 of 196
PDF
The Ring programming language version 1.6 book - Part 11 of 189
PDF
The Ring programming language version 1.5.2 book - Part 75 of 181
PDF
The Ring programming language version 1.6 book - Part 82 of 189
The Ring programming language version 1.5.3 book - Part 88 of 184
The Ring programming language version 1.5.4 book - Part 78 of 185
The Ring programming language version 1.5.1 book - Part 75 of 180
The Ring programming language version 1.8 book - Part 87 of 202
The Ring programming language version 1.7 book - Part 84 of 196
The Ring programming language version 1.6 book - Part 11 of 189
The Ring programming language version 1.5.2 book - Part 75 of 181
The Ring programming language version 1.6 book - Part 82 of 189

What's hot (20)

PDF
The Ring programming language version 1.5.2 book - Part 76 of 181
PDF
The Ring programming language version 1.10 book - Part 93 of 212
PDF
Testing CLI tools with Go
PDF
The Ring programming language version 1.5.4 book - Part 79 of 185
PDF
The Ring programming language version 1.10 book - Part 17 of 212
PDF
The Ring programming language version 1.6 book - Part 34 of 189
PDF
The Ring programming language version 1.5.2 book - Part 9 of 181
PDF
The Ring programming language version 1.9 book - Part 92 of 210
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 26 of 181
PDF
The Ring programming language version 1.9 book - Part 40 of 210
PDF
The Ring programming language version 1.10 book - Part 35 of 212
PDF
The Ring programming language version 1.2 book - Part 16 of 84
PDF
The Ring programming language version 1.6 book - Part 15 of 189
PDF
The Ring programming language version 1.7 book - Part 16 of 196
PDF
The Ring programming language version 1.8 book - Part 31 of 202
PDF
The Ring programming language version 1.5.1 book - Part 12 of 180
PDF
The Ring programming language version 1.7 book - Part 30 of 196
PDF
The Ring programming language version 1.3 book - Part 23 of 88
PDF
First Steps. (db4o - Object Oriented Database)
The Ring programming language version 1.5.2 book - Part 76 of 181
The Ring programming language version 1.10 book - Part 93 of 212
Testing CLI tools with Go
The Ring programming language version 1.5.4 book - Part 79 of 185
The Ring programming language version 1.10 book - Part 17 of 212
The Ring programming language version 1.6 book - Part 34 of 189
The Ring programming language version 1.5.2 book - Part 9 of 181
The Ring programming language version 1.9 book - Part 92 of 210
The Ring programming language version 1.5.1 book - Part 74 of 180
The Ring programming language version 1.5.2 book - Part 26 of 181
The Ring programming language version 1.9 book - Part 40 of 210
The Ring programming language version 1.10 book - Part 35 of 212
The Ring programming language version 1.2 book - Part 16 of 84
The Ring programming language version 1.6 book - Part 15 of 189
The Ring programming language version 1.7 book - Part 16 of 196
The Ring programming language version 1.8 book - Part 31 of 202
The Ring programming language version 1.5.1 book - Part 12 of 180
The Ring programming language version 1.7 book - Part 30 of 196
The Ring programming language version 1.3 book - Part 23 of 88
First Steps. (db4o - Object Oriented Database)
Ad

Similar to The Ring programming language version 1.9 book - Part 91 of 210 (16)

PDF
The Ring programming language version 1.10 book - Part 94 of 212
PDF
The Ring programming language version 1.7 book - Part 12 of 196
PDF
The Ring programming language version 1.5.3 book - Part 10 of 184
PDF
The Ring programming language version 1.5.4 book - Part 10 of 185
PDF
The Ring programming language version 1.9 book - Part 15 of 210
PDF
The Ring programming language version 1.8 book - Part 13 of 202
PDF
The Ring programming language version 1.6 book - Part 81 of 189
PDF
The Ring programming language version 1.9 book - Part 90 of 210
PDF
The Ring programming language version 1.5.3 book - Part 89 of 184
PDF
The Ring programming language version 1.5.1 book - Part 9 of 180
PDF
The Ring programming language version 1.8 book - Part 88 of 202
PDF
The Ring programming language version 1.5.1 book - Part 25 of 180
PDF
The Ring programming language version 1.9 book - Part 33 of 210
PDF
The Ring programming language version 1.3 book - Part 60 of 88
PDF
The Ring programming language version 1.5.3 book - Part 87 of 184
PDF
The Ring programming language version 1.4.1 book - Part 3 of 31
The Ring programming language version 1.10 book - Part 94 of 212
The Ring programming language version 1.7 book - Part 12 of 196
The Ring programming language version 1.5.3 book - Part 10 of 184
The Ring programming language version 1.5.4 book - Part 10 of 185
The Ring programming language version 1.9 book - Part 15 of 210
The Ring programming language version 1.8 book - Part 13 of 202
The Ring programming language version 1.6 book - Part 81 of 189
The Ring programming language version 1.9 book - Part 90 of 210
The Ring programming language version 1.5.3 book - Part 89 of 184
The Ring programming language version 1.5.1 book - Part 9 of 180
The Ring programming language version 1.8 book - Part 88 of 202
The Ring programming language version 1.5.1 book - Part 25 of 180
The Ring programming language version 1.9 book - Part 33 of 210
The Ring programming language version 1.3 book - Part 60 of 88
The Ring programming language version 1.5.3 book - Part 87 of 184
The Ring programming language version 1.4.1 book - Part 3 of 31
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
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PPT
Introduction Database Management System for Course Database
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
medical staffing services at VALiNTRY
PPTX
history of c programming in notes for students .pptx
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
AI in Product Development-omnex systems
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
Softaken Excel to vCard Converter Software.pdf
PPTX
Operating system designcfffgfgggggggvggggggggg
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PPTX
ai tools demonstartion for schools and inter college
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
Understanding Forklifts - TECH EHS Solution
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
Introduction Database Management System for Course Database
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Odoo Companies in India – Driving Business Transformation.pdf
medical staffing services at VALiNTRY
history of c programming in notes for students .pptx
Design an Analysis of Algorithms I-SECS-1021-03
AI in Product Development-omnex systems
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Upgrade and Innovation Strategies for SAP ERP Customers
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Softaken Excel to vCard Converter Software.pdf
Operating system designcfffgfgggggggvggggggggg
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
ai tools demonstartion for schools and inter college
Design an Analysis of Algorithms II-SECS-1021-03
How to Migrate SBCGlobal Email to Yahoo Easily
Understanding Forklifts - TECH EHS Solution

The Ring programming language version 1.9 book - Part 91 of 210

  • 1. Ring Documentation, Release 1.9 ring_gettemp_var 4 00000000 0 0 ccatcherror 1 NULL 0 0 ring_settemp_var 4 00000000 0 0 ring_tempflag_var 2 0 0 0 stdin 3 50512DB8 file 0 0 0 stdout 3 50512DD8 file 0 0 0 stderr 3 50512DF8 file 0 0 0 this 4 00000000 0 0 sysargv 3 B:ringbin/ring B:/ring/tests/scripts/memorylist.ring 0 0 x 2 10 0 0 y 77.13. ringvm_memorylist() function 869
  • 2. Ring Documentation, Release 1.9 2 20 0 0 77.14 ringvm_calllist() function The Function return a list of the functions call list. Each List Member is a list contains the next items • Function Type • Function Name • Program Counter (PC) • Stack Pointer (SP) • Temp. Memory List • Method or Function Flag • Caller PC • FuncExec Flag • ListStart Flag • Nested Lists Pointer • State List Syntax: RingVM_CallList() ---> List Example: hello() func hello test() func test mylist = ringvm_calllist() for t in mylist see t[2] + nl next Output: function hello() in file B:/ring/tests/scripts/calllist.ring called from line 1 function test() in file B:/ring/tests/scripts/calllist.ring called from line 3 ringvm_calllist 77.15 ringvm_fileslist() function Function return a list of the Ring Files. 77.14. ringvm_calllist() function 870
  • 3. Ring Documentation, Release 1.9 Syntax: RingVM_FilesList() ---> List Example: load "stdlib.ring" see ringvm_fileslist() Output: B:/ring/tests/scripts/fileslist.ring B:ringbinstdlib.ring eval stdlib.ring stdlib.rh stdclasses.ring stdfunctions.ring stdbase.ring stdstring.ring stdlist.ring stdstack.ring stdqueue.ring stdmath.ring stddatetime.ring stdfile.ring stdsystem.ring stddebug.ring stddatatype.ring stdconversion.ring stdodbc.ring stdmysql.ring stdsecurity.ring stdinternet.ring stdhashtable.ring stdtree.ring 77.16 ringvm_settrace() The function ringvm_settrace() determine the Trace function name The trace function is a Ring function that will be called for each event Syntax: RingVM_SetTrace(cCode) 77.17 ringvm_tracedata() Inside the function that we will use for tracing events We can use the ringvm_tracedata() function to get the event data. The event data is a list contains the next items • The Source Code Line Number 77.16. ringvm_settrace() 871
  • 4. Ring Documentation, Release 1.9 • The Source File Name • The Function/Method Name • Method or Function (Bool : True=Method, False=Function/File) Syntax: RingVM_TraceData() ---> aDataList 77.18 ringvm_traceevent() Inside the function that we will use for tracing events We can use ringvm_traceevent() to know the event type • New Line • Before Function • After Function • Runtime Error • Before C Function • After C Function Syntax: RingVM_TraceEvent() ---> nTraceEvent 77.19 ringvm_tracefunc() The function return the name of the function that we are using for tracing events. Syntax: RingVM_TraceEvent() ---> cCode 77.20 ringvm_scopescount() We can use the RingVM_ScopesCount() function to know the number of scopes used in the application. In the start of the program, We have the (global scope only) When we call a function, A new scope is created. When the function execution is done, the function scope is deleted. Syntax: RingVM_ScopesCount() ---> nScopes 77.18. ringvm_traceevent() 872
  • 5. Ring Documentation, Release 1.9 77.21 ringvm_evalinscope() The function ringvm_evalinscope() is similar to the eval() function Unlike eval() which execute the code in the current scope Using RingVM_EvalInScope() we can execute the scope in a specific scope. Syntax: RingVM_EvalInScope(nScope,cCode) 77.22 ringvm_passerror() When we have runtime error, After printing the Error message, Ring will end the execution of the program. Using ringvm_passerror() we can avoid that, and continue the execution of our program. Syntax: RingVM_PassError() 77.23 ringvm_hideerrormsg() We can disable/enable displaying the runtime error messages using the RingVM_HideErrorMsg() function. Syntax: RingVM_HideErrorMsg(lStatus) 77.24 ringvm_callfunc() We can call a function from a string without using eval() using the ringvm_callfunc() Syntax: RingVM_CallFunc(cFuncName) 77.25 Example - Using the Trace Functions The next example use the Trace Functions to trace the program Events! In practical, We will use the Trace Library instead of these low level functions! load "tracelib.ring" ringvm_settrace("mytrace()") see "Hello, world!" + nl see "Welcome" + nl see "How are you?" +nl mytest() 77.21. ringvm_evalinscope() 873
  • 6. Ring Documentation, Release 1.9 new myclass { mymethod() } func mytest see "Message from mytest" + nl func mytrace see "====== The Trace function is Active ======" + nl + "Trace Function Name : " + ringvm_TraceFunc() + nl + "Trace Event : " switch ringvm_TraceEvent() on TRACEEVENT_NEWLINE see "New Line" on TRACEEVENT_NEWFUNC see "New Function" on TRACEEVENT_RETURN see "Return" on TRACEEVENT_ERROR see "Error" on TRACEEVENT_BEFORECFUNC see "Before C Function" on TRACEEVENT_AFTERCFUNC see "After C Function" off see nl + "Line Number : " + ringvm_tracedata()[TRACEDATA_LINENUMBER] + nl + "File Name : " + ringvm_tracedata()[TRACEDATA_FILENAME] + nl + "Function Name : " + ringvm_tracedata()[TRACEDATA_FUNCNAME] + nl + "Method or Function : " if ringvm_tracedata()[TRACEDATA_METHODORFUNC] = TRACEDATA_METHODORFUNC_METHOD see "Method" else if ringvm_tracedata()[TRACEDATA_FUNCNAME] = NULL see "Command" else see "Function" ok ok see nl + Copy("=",42) + nl class myclass func mymethod see "Message from mymethod" + nl Output: ====== The Trace function is Active ====== Trace Function Name : mytrace() Trace Event : After C Function Line Number : 3 File Name : test1.ring Function Name : ringvm_settrace Method or Function : Function ========================================== ====== The Trace function is Active ====== Trace Function Name : mytrace() Trace Event : New Line Line Number : 5 File Name : test1.ring Function Name : Method or Function : Command ========================================== Hello, world! ====== The Trace function is Active ====== 77.25. Example - Using the Trace Functions 874
  • 7. Ring Documentation, Release 1.9 Trace Function Name : mytrace() Trace Event : New Line Line Number : 6 File Name : test1.ring Function Name : Method or Function : Command ========================================== Welcome ====== The Trace function is Active ====== Trace Function Name : mytrace() Trace Event : New Line Line Number : 7 File Name : test1.ring Function Name : Method or Function : Command ========================================== How are you? ====== The Trace function is Active ====== Trace Function Name : mytrace() Trace Event : New Line Line Number : 8 File Name : test1.ring Function Name : Method or Function : Command ========================================== ====== The Trace function is Active ====== Trace Function Name : mytrace() Trace Event : New Function Line Number : 8 File Name : test1.ring Function Name : mytest Method or Function : Function ========================================== ====== The Trace function is Active ====== Trace Function Name : mytrace() Trace Event : New Line Line Number : 12 File Name : test1.ring Function Name : mytest Method or Function : Function ========================================== Message from mytest ====== The Trace function is Active ====== Trace Function Name : mytrace() Trace Event : New Line Line Number : 14 File Name : test1.ring Function Name : mytest Method or Function : Function ========================================== ====== The Trace function is Active ====== Trace Function Name : mytrace() Trace Event : Return Line Number : 8 File Name : test1.ring Function Name : Method or Function : Command ========================================== 77.25. Example - Using the Trace Functions 875
  • 8. Ring Documentation, Release 1.9 ====== The Trace function is Active ====== Trace Function Name : mytrace() Trace Event : New Line Line Number : 9 File Name : test1.ring Function Name : Method or Function : Command ========================================== ====== The Trace function is Active ====== Trace Function Name : mytrace() Trace Event : New Line Line Number : 43 File Name : test1.ring Function Name : Method or Function : Command ========================================== ====== The Trace function is Active ====== Trace Function Name : mytrace() Trace Event : Before C Function Line Number : 9 File Name : test1.ring Function Name : ismethod Method or Function : Function ========================================== ====== The Trace function is Active ====== Trace Function Name : mytrace() Trace Event : After C Function Line Number : 9 File Name : test1.ring Function Name : ismethod Method or Function : Function ========================================== ====== The Trace function is Active ====== Trace Function Name : mytrace() Trace Event : New Function Line Number : 9 File Name : test1.ring Function Name : mymethod Method or Function : Method ========================================== ====== The Trace function is Active ====== Trace Function Name : mytrace() Trace Event : New Line Line Number : 44 File Name : test1.ring Function Name : mymethod Method or Function : Method ========================================== Message from mymethod ====== The Trace function is Active ====== Trace Function Name : mytrace() Trace Event : Return Line Number : 9 File Name : test1.ring Function Name : Method or Function : Command ========================================== ====== The Trace function is Active ====== 77.25. Example - Using the Trace Functions 876
  • 9. Ring Documentation, Release 1.9 Trace Function Name : mytrace() Trace Event : Before C Function Line Number : 9 File Name : test1.ring Function Name : ismethod Method or Function : Function ========================================== ====== The Trace function is Active ====== Trace Function Name : mytrace() Trace Event : After C Function Line Number : 9 File Name : test1.ring Function Name : ismethod Method or Function : Function ========================================== ====== The Trace function is Active ====== Trace Function Name : mytrace() Trace Event : Before C Function Line Number : 9 File Name : test1.ring Function Name : ismethod Method or Function : Function ========================================== ====== The Trace function is Active ====== Trace Function Name : mytrace() Trace Event : After C Function Line Number : 9 File Name : test1.ring Function Name : ismethod Method or Function : Function ========================================== ====== The Trace function is Active ====== Trace Function Name : mytrace() Trace Event : New Line Line Number : 11 File Name : test1.ring Function Name : Method or Function : Command ========================================== 77.26 Example - The Trace Library The next example uses the Trace functions provided by the Ring language to create the Trace library. Using the Trace library we have nice Tracing tools and Interaction debugger too. # Trace Events TRACEEVENT_NEWLINE = 1 TRACEEVENT_NEWFUNC = 2 TRACEEVENT_RETURN = 3 TRACEEVENT_ERROR = 4 TRACEEVENT_BEFORECFUNC = 5 TRACEEVENT_AFTERCFUNC = 6 # Trace Data TRACEDATA_LINENUMBER = 1 77.26. Example - The Trace Library 877
  • 10. Ring Documentation, Release 1.9 TRACEDATA_FILENAME = 2 TRACEDATA_FUNCNAME = 3 TRACEDATA_METHODORFUNC = 4 # Method of Function TRACEDATA_METHODORFUNC_METHOD = TRUE TRACEDATA_METHODORFUNC_NOTMETHOD = FALSE TRACE_BREAKPOINTS = TRUE TRACE_TEMPLIST = [] func Trace cType switch trim(lower(cType)) on :AllEvents ringvm_settrace("TraceLib_AllEvents()") on :Functions ringvm_settrace("TraceLib_Functions()") on :PassError ringvm_settrace("TraceLib_PassError()") on :Debugger ringvm_settrace("TraceLib_Debugger()") on :LineByLine ringvm_settrace("TraceLib_LineByLine()") off func TraceLib_AllEvents if right(ringvm_tracedata()[TRACEDATA_FILENAME],13) = "tracelib.ring" return ok see "====== The Trace function is Active ======" + nl + "Trace Function Name : " + ringvm_TraceFunc() + nl + "Trace Event : " switch ringvm_TraceEvent() on TRACEEVENT_NEWLINE see "New Line" on TRACEEVENT_NEWFUNC see "New Function" on TRACEEVENT_RETURN see "Return" on TRACEEVENT_ERROR see "Error" on TRACEEVENT_BEFORECFUNC see "Before C Function" on TRACEEVENT_AFTERCFUNC see "After C Function" off see nl + "Line Number : " + ringvm_tracedata()[TRACEDATA_LINENUMBER] + nl + "File Name : " + ringvm_tracedata()[TRACEDATA_FILENAME] + nl + "Function Name : " + ringvm_tracedata()[TRACEDATA_FUNCNAME] + nl + "Method or Function : " if ringvm_tracedata()[TRACEDATA_METHODORFUNC] = TRACEDATA_METHODORFUNC_METHOD see "Method" else if ringvm_tracedata()[TRACEDATA_FUNCNAME] = NULL see "Command" else see "Function" ok ok see nl + Copy("=",42) + nl 77.26. Example - The Trace Library 878