For those developing thinBasic modules, few words on new SDK interface function "thinBasic_DeclareFunction".
thinBasic_DeclareFunction is still experimental and can change in final thinBasic release.
It is declared as follows:
[code=freebasic] '----------------------------------------------------------------------------
'thinBasic_DeclareFunction
'----------------------------------------------------------------------------
' Add a new function using DECLARE statement and function pointer
'----------------------------------------------------------------------------
Declare Function thinBasic_DeclareFunction _
Lib "thinCore.DLL" _
Alias "thinBasic_DeclareFunction" _
( _
ByVal sDeclare As String , _
ByVal pFun As Dword _
) As Long[/code]
Its purpose is to pass to thinBasic Core engine a string used to declare your module function plus your module function pointer.
String passed to thinBasic Core follows the same syntax as a standard declare. In this way your module function can receive directly from thinBasic Core engine the necessary parameters without have to parse them in module.
An example. Imagine you want to create your personalized Left$ function called MyLeft. Using thinBasic_DeclareFunction SDK function you can now do like the following.
Create your module function in the classic way:
[code=freebasic] '----------------------------------------------------------------------------
Function MyInternalLeft(ByVal s As String, ByVal l As Long) As String
'----------------------------------------------------------------------------
Function = Left$(s, l) & "Whatever"
End Function[/code]
Inside "LoadLocalSymbols" function (it must always be present in your DLL in order to be a thinBasic module) define your new function in the following way:
[code=freebasic]
thinBasic_DeclareFunction "DECLARE FUNCTION MyLeft(BYVAL s as string, byval l as long) AS string", CodePtr(MyInternalLeft)
[/code]
thinBasic Core engine will parse your string declare and will automatically connect a new keyword called "MyLeft" with your "MyInternalLeft" registering all needed parameters and their passing methods.
Again, this new SDK is experimental and more limited compared with classic way of creating module functions but can help.
Regards
Eros
Bookmarks