Dear kcvinu,
thinBasic pseudo OOP is a little different from standard OOP languages that use Classes/Methods/Instance variables.
thinBasic has used TYPEs to implement a sort of OOP. So you have to use TYPE/END TYPE
Correct possible script based on your code can be the following:
'---Load console Module
Uses "Console"
'---Type definition
Type MyClass
'---Local variables
a As Integer
b As String
'---Default constructor.
'---In this special functions can take place initialization of the type variables
Function _Create()
Me.a = 1500
Me.b = "This is from class"
End Function
'---Type method
Function MyFunc(ByVal c As Integer) As Long
Return C * 10
End Function
End Type
Dim My_cls As New MyClass
PrintL My_cls.b
PrintL "====================="
PrintL My_cls.a
PrintL "====================="
PrintL My_cls.MyFunc(5)
WaitKey
You can put you TYPE/END TYPE declaration into a separate file and use #INCLUDE to include its source code in many different scripts. See #INCLUDE help to have more info on how to use it.
Example
'---Load console Module
Uses "Console"
#INCLUDE "MyClassIncludeFile.tbasic"
Dim My_cls As New MyClass
PrintL My_cls.b
PrintL "====================="
PrintL My_cls.a
PrintL "====================="
PrintL My_cls.MyFunc(5)
WaitKey
You can place your include files in any directory you want but you need to tell in your script where to load them. Usually included files are placed into a sub directory of your project and you can use partial include dir like:
#INCLUDE ".\IncludeDirectory\MyClassIncludeFile.tbasic"
Instead Modules are not source code but compiled DLL specifically developed for thinBasic using thinBasic SDK.
Modules are loaded into the script using the keyword USES
Ciao
Eros
Bookmarks