IT-Consultant: Charles Pegge > OxygenBasic
Modules for O2
Nicola_Piano:
Hi Charles,
I find it really interesting to use the module.
Is there an example in version 050p1? If so, what is it called?
... thanks again for your work.
Cheers
Charles Pegge:
Hi Nicola,
I have not produced any examples yet. It is quite hard to demonstrate the potential of modules on a small scale.
As I see it, modules are placed at the top of the language structural hierarchy:
program
module
class
procedure
subroutine
block
statement
expression
instruction
Here is on example linking a visible function to an internal function:
--- Code: ---========
module X
========
interface
'
!* fi(int a) as int
'
inner
'
function ff(int a) as int
print "ok " a
end function
'
'links
@fi=@ff
'
end inner
'
end module
'
fi(3)
--- End code ---
Another example demonstrating how to retrofit a module around existing code, exposing only a few functions:
--- Code: ---module
sys p1,p2,p3,p4
inner
============
uses console
============
p1=@input
p2=@output
p3=@cls
p4=@getkey
end inner
! input() as string at p1
! output(string s) at p2
! cls () at p3
! pause() as int at p4
end module
--- End code ---
Nicola_Piano:
Charles,
it's really interesting. I tried and saw that you can have different outputs and inputs (console or win) with this module.
(Did I get it right? :))
--- Code: ---module
sys p1,p2,p3,p4
inner
============
uses console
============
p1=@input
p2=@output
p3=@cls
p4=@getkey
end inner
! input() as string at p1
! output(string s) at p2
! cls () at p3
! pause() as int at p4
end module
string a=input 'input from console
output a 'print in console
print a 'print in wind
output a 'print in console
pause 'wait a key in console.
--- End code ---
Zlatko Vid:
well it looks like mini sub - program
Nicola_Piano:
Hi
Rather than a sub, it creates an environment that can be interfaced with another environment.
Or am I wrong?
Cheers
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version