Nice, thanks for working further on Oxygen! I plan on using it with my next game which I will be at least prototyping in thinBasic.
Class Libraries
You can now create DLLs containing classes as well as SUBs an Functions. They are declared in much the same way:
class greeting lib `chatter.dll` alias `greeting`
followed by the rest of the class header.
On the library side, the classes must be marked export
class greeting alias `greeting` export
If no Alias is specified then the default is a lowercase match for the class name used.
Internally the methods table is passed from the library to the client at load time. This ensures that new classes can be derived from the the library classes.
The script below first generates a miinimal class library chatter.dll containing one class with 2 methods. The second parts of the script creates an object with it.
Oxygen Update: http://community.thinbasic.com/index.php?topic=2517
[code=thinbasic]
uses "oxygen","file"
dim src as string
'
'
'
' ###############
' ###################
' ### ###
' ### ### ###
' ### ## ## ###
' ### ## ## ###
' ### ## ## ###
' ### ## ## ###
' ### ## ## ###
' ### #### ## ###
' ### #### ###
' ### ###
' ### ###
' #############
' #########
'----------------------
'GENERATE CLASS LIBRARY
'======================
src ="
#basic
#file `chatter.dll`
'-------------------------------------
class greeting alias `greeting` export
'=====================================
method hello(n as string)
;
method goodbye(n as string)
/
a as long
end class
methods of greeting
method hello(n as string)
print `Hello ` n
end method
method goodbye(n as string)
print `Goodbye ` n
end method
end methods of greeting
sub finish()
terminate
end sub
"
'msgbox 0,o2_prep src
o2_basic src
if len(o2_error) then
msgbox 0, o2_error : stop
end if
o2_exec
' ##### ###### ###### ###### ######
' ######## ######### ######### ######### ###-*-####
' ## ## ## ## ## ## ## ## #########
' ## ## ## ## ## ## ## ## ##
' ## ## ## ## ## ## ## ## ##
' ## ## ## ## ## ## ## ## ##
' ## ## ## ## ## ## ## ## ##
' ## ## ## ## ## ## ## ## ##
' ## ########## ########## ########## ##########
' # ###### ###### ###### ######
'
'----------------------
'TEST THE CLASS LIBRARY
'======================
src="
#basic
'------------------------------------------------
class greeting lib `chatter.dll` alias `greeting`
'================================================
method hello(n as string)
method goodbye(n as string)
/
a as long
end class
dim g as greeting
g.goodbye `moon`
g.hello `earth`
xit:
terminate
"
file_save ("t.txt",o2_view src )
'msgbox 0,o2_prep src
o2_basic src
if len(o2_error) then
msgbox 0, o2_error : stop
end if
o2_exec
'msgbox 0,o2_error
[/code]
Nice, thanks for working further on Oxygen! I plan on using it with my next game which I will be at least prototyping in thinBasic.
Hohoo,
that is pretty powerful Charles!
Learn 3D graphics with ThinBASIC, learn TBGL!
Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB
Charles, this is really getting exciting, thanks for the news.
Mike, I will be excited to see what you come up with, good luck on your project!
Acer Notebook: Win 10 Home 64 Bit, Core i7-4702MQ @ 2.2Ghz, 12 GB RAM, nVidia GTX 760M and Intel HD 4600
Raspberry Pi 3: Raspbian OS use for Home Samba Server and Test HTTP Server
Bookmarks