View Full Version : FreeBASIC module SDK for thinBasic_1.9.x.x
D.J.Peters
20-05-2013, 17:56
More up to date FreeBASIC thinBasic module SDK.
I created new importlib and thinCore.bi include file.
all ALIAS code removed (extern "MS-Windows" end extern is the key)
optional params now really optional
added ext data type
added missing exports for script calling
...
Download: thinBasic_1.9.x.x_FreeBASIC_SDK.zip (http://www.alice-dsl.net/d.j.peters/thinbasic/thinBasic_1.9.x.x_FreeBASIC_SDK.zip)
Joshy
Petr Schreiber
20-05-2013, 18:35
This is lot of work and time invested, good job!
I found a few functions which are still missing in the above, I list here the PB originals. Please don't feel it as "... and you should add them right now", just wanted to make your life easier by searching the differences for your possible future updates of FreeBASIC SDK.
For launching ThinBASIC scripts:
%thinBasic_BufferType_IsFile = 0&
%thinBasic_BufferType_IsScript = 1&
Declare Function thinBasic_Init _
Lib "thinCore.dll" _
Alias "thinBasic_Init" _
( _
ByVal hWnd As Long , _
ByVal cInstance As Long , _
ByVal sKey As String _
) As Long
Declare Function thinBasic_Release _
Lib "thinCore.dll" _
Alias "thinBasic_Release" _
( _
ByVal hScript As Long _
) As Long
Declare Function thinBasic_Run _
Lib "thinCore.dll" _
Alias "thinBasic_Run" _
( _
ByVal hScript As Long , _
byval sBuffer As string , _
ByVal BufferType As Long , _
Optional ByVal Options As Long , _
ByVal DebugMode As Long , _
ByVal LogMode As Long , _
ByVal ObfuscateMode As Long , _
ByVal CallingProgram As Long , _
ByVal DependancyMode As Long _
) As Long
For code tips:
'----------------------------------------------------------------------------
'thinBasic_LoadSymbolEX
'----------------------------------------------------------------------------
' Description
' Creates e new keyword inside interpreter.
' You define your own Function or Sub inside your program. Then call
' thinBasic_LoadSymbol to add a new keyword connected to your new function/sub
'
' Parameters
' SymbolName : Name you want to give to your sub or function inside the
' interpreter. It is the new keyword name.
'
' ReturnCode : specify what kind of var your function returns
' Use predefined constants:
' %thinBasic_ReturnNumber
' %thinBasic_ReturnString
' %thinBasic_ReturnNone
' If SymbolName will end with "$" char, ReturnCode will
' be forced to %thinBasic_ReturnString
' Note: if you pass a pointer to a SUB routine and ReturnCode
' is different from %thinBasic_ReturnNone, a GPF will be
' fired by the Operating System.
' Note: if ReturnCode <= 0 then %thinBasic_ReturnNone will be
' assumed
'
' FunctionOrSubPointer:
' DWORD returned by CODEPTR function pointing to the function
' that will be called when SymbolName keyword will be encountered
' during script execution
'
' ForceOverWrite:
' If different from 0 it means that even if SymbolName
' already exists as a keyword, you want to overwrite it with
' a new one.
' For example, if you want to overwrite behave of MID$
' creating your own MID$ function, set this parameter to a value
' > 0 like in this example:
' thinBasic_LoadSymbol("MID$", %thinBasic_ReturnString, CODEPTR(MyMid), 1)
' sSyntax:
' Syntax of the symbol name
' sHelp:
' help about the symbol name
'
' Possible Return Code
' >0 = no error, return the associated SymbolName ID
' -1 = empty SymbolName
' -2 = duplicated SymbolName and no ForceOverWrite flag
' -3 = invalid sub/function pointer
' -4 = SymbolName contains invalid char(s)
'
' Example
' thinBasic_LoadSymbol "MyNewFunction", %thinBasic_ReturnNumber, CODEPTR(MyFunc)
'----------------------------------------------------------------------------
Declare Function thinBasic_LoadSymbolEX _
Lib "thinCore.DLL" _
Alias "thinBasic_LoadSymbolEX" _
( _
ByVal SymbolName As String , _
ByVal ReturnCode As Long , _
ByVal FunctionOrSubPointer As Dword , _
Optional _
ByVal ForceOverWrite As Long , _
ByVal sSyntax As String , _
ByVal sHelp As String _
) As Long
Variables:
'----------------------------------------------------------------------------
'thinBasic_VariableGetList
'----------------------------------------------------------------------------
' Returns a string with the list of all variables of a specific stack level
' If StackLevel is missing, current stack level will be returned
'----------------------------------------------------------------------------
Declare Function thinBasic_VariableGetList _
LIB "thinCore.DLL" _
Alias "thinBasic_VariableGetList" _
( _
Optional _
ByVal lStackLevel As Long , _
ByVal sSep As String _
) As String
'----------------------------------------------------------------------------
'----------------------------------------------------------------------------
'thinBasic_VariableGetValueNum
'----------------------------------------------------------------------------
' Returns numeric value of a numeric variable given variable name and optionally array index
'----------------------------------------------------------------------------
Declare Function thinBasic_VariableGetValueNum _
LIB "thinCore.DLL" _
Alias "thinBasic_VariableGetValueNum" _
( _
ByVal SearchKey As String , _
Optional ByVal lIndex As Long _
) As Ext
'----------------------------------------------------------------------------
Declare Function thinBasic_VariableGetInfoPtr _
Lib "thinCore.DLL" _
Alias "thinBasic_VariableGetInfoPtr" _
( _
ByVal pVariable As Long , _ '---A pointer to Variable
ByRef MainType As Long , _ '---ATTENTION: parameter passed BYREF will return info
ByRef SubType As Long , _ '---ATTENTION: parameter passed BYREF will return info
ByRef IsArray As Long _ '---ATTENTION: parameter passed BYREF will return info
) As Long
Variable subtypes:
%SubType_Boolean = 2?
%SubType_String = 30?
Variable maintypes:
%MainType_GUID = 40? : %MainType_IsGUID = %MainType_GUID
%MainType_IsString = %MainType_String
%MainType_IsVariant = %MainType_Variant
%MainType_IsUDT = %MainType_UDT
%MainType_PTR = 70? : %MainType_IsPTR = %MainType_PTR
%MainType_Object = 80? : %MainType_IsObject = %MainType_Object
%MainType_Class = 90? : %MainType_IsClass = %MainType_Class
Arrays:
%Array_ElementsAreFixed = 15& '%TRUE if elements are fixed size, like fixed strings or UDT
%Array_UBoundDim_1 = 91& 'Returns the Upper Bound of dimension 1
%Array_UBoundDim_2 = 92& 'Returns the Upper Bound of dimension 2
%Array_UBoundDim_3 = 93& 'Returns the Upper Bound of dimension 3
Adding:
'----------------------------------------------------------------------------
'thinBasic_AddUdt
'----------------------------------------------------------------------------
' Add a new UDT structure
'----------------------------------------------------------------------------
Declare Function thinBasic_AddUdt _
LIB "thinCore.DLL" _
Alias "thinBasic_AddUdt" _
( _
ByVal sUDT_Code As String _
) As Long
'----------------------------------------------------------------------------
'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
Functions:
'----------------------------------------------------------------------------
'thinBasic_FunctionGetPtr
'----------------------------------------------------------------------------
'----------------------------------------------------------------------------
Declare Function thinBasic_FunctionGetPtr _
Lib "thinCore.DLL" _
Alias "thinBasic_FunctionGetPtr" _
( _
ByVal fName As String _
) As Long
'----------------------------------------------------------------------------
'thinBasic_FunctionGetPtr
'----------------------------------------------------------------------------
'----------------------------------------------------------------------------
Declare Function thinBasic_FunctionGetName _
Lib "thinCore.DLL" _
Alias "thinBasic_FunctionGetName" _
( _
ByVal FunctionPtr As Long _ '---PTR to function returned by (for example) thinBasic_FunctionGetPtr
) As String
'----------------------------------------------------------------------------
'thinBasic_FunctionIsCallBack
'----------------------------------------------------------------------------
' Determine if fucntion passed as PTR has been defined as CALLBACK function in script
'----------------------------------------------------------------------------
Declare Function thinBasic_FunctionIsCallBack _
Lib "thinCore.DLL" _
Alias "thinBasic_FunctionIsCallBack" _
( _
ByVal FunctionPtr As Long _ '---PTR to function returned by thinBasic_FunctionGetPtr
) As Long
'----------------------------------------------------------------------------
'thinBasic_FunctionGetCBParam
'----------------------------------------------------------------------------
' Returns the value of a designated CallBack pseudo variable.
' ATTENTION: interface function valid only whileinside a callback function
'----------------------------------------------------------------------------
' Parameters:
' CBParamType: one of the following equates
'---Equates for CBParamType
%CBParam_CBHNDL = 100&
%CBParam_CBMSG = 110&
%CBParam_CBCTL = 120&
%CBParam_CBCTLMSG = 130&
%CBParam_CBLPARAM = 140&
%CBParam_CBWPARAM = 150&
%CBParam_CBNMCODE = 160&
%CBParam_CBNMHDR = 170&
%CBParam_CBNMHWND = 180&
%CBParam_CBNMID = 190&
' lError: a pointer to a long variable that will receive possible error variables
' Possible errors:
' -10: not inside at any function
' -20: inside a function but not a callback function
' -30: unsupported/invalid CBParamType
'----------------------------------------------------------------------------
Declare Function thinBasic_FunctionGetCBParam _
Lib "thinCore.DLL" _
Alias "thinBasic_FunctionGetCBParam" _
( _
ByVal CBParamType As Long , _
Optional ByVal lError As Long Ptr _
) As Long
'----------------------------------------------------------------------------
'thinBasic_FunctionGetNumberOfParams
'----------------------------------------------------------------------------
' Returns the number of parameters defined in a script function
'----------------------------------------------------------------------------
Declare Function thinBasic_FunctionGetNumberOfParams _
Lib "thinCore.DLL" _
Alias "thinBasic_FunctionGetNumberOfParams" _
( _
ByVal FunctionPtr As Long _ '---PTR to function returned by thinBasic_FunctionGetPtr
) As Long
'----------------------------------------------------------------------------
'thinBasic_FunctionGetReturnMainType
'----------------------------------------------------------------------------
' Gets the main data type returned by a script function. See %VarMainType* equates above
'----------------------------------------------------------------------------
Declare Function thinBasic_FunctionGetReturnMainType _
Lib "thinCore.DLL" _
Alias "thinBasic_FunctionGetReturnMainType" _
( _
ByVal FunctionPtr As Long _ '---PTR to function returned by thinBasic_FunctionGetPtr
) As Long
'----------------------------------------------------------------------------
'thinBasic_FunctionSimpleCall
'----------------------------------------------------------------------------
' Call a script function and optionally returns it value (numeric or string)
'----------------------------------------------------------------------------
Declare Function thinBasic_FunctionSimpleCall _
Lib "thinCore.DLL" _
Alias "thinBasic_FunctionSimpleCall" _
( _
ByVal FunctionName As String, _ '---Name of the function
Optional _
ByVal ptrEXT As Ext Ptr, _ '---Used to get back from the called function a numeric value
ByVal ptrSTR As String Ptr _ '---Used to get back from the called function a string value
) As Long
Parsing:
'----------------------------------------------------------------------------
'thinBasic_ParsePtrToSomething
'----------------------------------------------------------------------------
' Parse whatever and return a PTR to something
'----------------------------------------------------------------------------
Declare Function thinBasic_ParsePtrToSomething _
LIB "thinCore.DLL" _
Alias "thinBasic_ParsePtrToSomething" _
( _
ByRef VariablePtr As Long _ '---ATTENTION: parameter passed BYREF will return info
) As Long
'----------------------------------------------------------------------------
'thinBasic_ParseVariableInfo
'----------------------------------------------------------------------------
' Parameters (all passed BYREF ... AS LONG):
' - VariablePtr pointer to internal thinBasic Core engine data structure
' used to store variable info
' - MainType variable main type
' - SubType variable sub type
' - ElementsAreFixed %TRUE if elements inside data buffer are fixed size.
' For example will return %TRUE:
' - fixed STRING size, the one declared ... AS STRING * size
' - fixed ASCIIZ size, the one declared ... AS ASCIIZ * size
' - UDT variables
' - TotElements total number of elements in variable. Usually 1 if
' variable is not an array
' - ElementSize size of the single element. For example if variable is a
' LONG, ElementSize = 4. If EXT ElementSize = 10
' if variable is a UDT, it will depend from UDT to UDT.
' - DataPtr pointer to variable data
' - AbsPos absolute position inside the array if variable is an array
' if variable is not an array 1 is returned
'----------------------------------------------------------------------------
declare function thinBasic_ParseVariableInfo _
LIB "thinCore.DLL" _
alias "thinBasic_ParseVariableInfo" _
( _
byref VariablePtr as long , _ '---ATTENTION: parameter passed BYREF will return info
byref MainType as long , _ '---ATTENTION: parameter passed BYREF will return info
byref SubType as long , _ '---ATTENTION: parameter passed BYREF will return info
byref ElementsAreFixed as long , _ '---ATTENTION: parameter passed BYREF will return info
byref TotElements as long , _ '---ATTENTION: parameter passed BYREF will return info
byref ElementSize as long , _ '---ATTENTION: parameter passed BYREF will return info
byref DataPtr as long , _ '---ATTENTION: parameter passed BYREF will return info
byref AbsPos as long _ '---ATTENTION: parameter passed BYREF will return info
) as long
'------------------------------------------------------------------------------
'---
' Parse one string expression.
Declare Sub thinBasic_ParseStr Lib "thinCore.DLL" Alias "thinBasic_ParseStr" (ByRef sResult As String)
'---
' Parse a variant variable (scalar or array) and returns its pointer
Declare Function thinBasic_ParseVariant Lib "thinCore.DLL" Alias "thinBasic_ParseVariant" () As Dword
Declare Function thinBasic_CheckSemicolon_Mandatory Lib "thinCore.DLL" Alias "thinBasic_CheckSemicolon_Mandatory" () As Long
Declare Function thinBasic_CheckSemicolon_Optional Lib "thinCore.DLL" Alias "thinBasic_CheckSemicolon_Optional" () As Long
Declare Function thinBasic_CheckEqual_Mandatory Lib "thinCore.DLL" Alias "thinBasic_CheckEqual_Mandatory" () As Long
Declare Function thinBasic_CheckEqual_Optional Lib "thinCore.DLL" Alias "thinBasic_CheckEqual_Optional" () As Long
Declare Function thinBasic_CheckPoint_Mandatory Lib "thinCore.DLL" Alias "thinBasic_CheckPoint_Mandatory" () As Long
Declare Function thinBasic_CheckPoint_Optional Lib "thinCore.DLL" Alias "thinBasic_CheckPoint_Optional" () As Long
Declare Function thinBasic_CheckPlus_Optional Lib "thinCore.DLL" Alias "thinBasic_CheckPlus_Optional" () As Long
Declare Function thinBasic_CheckMinus_Optional Lib "thinCore.DLL" Alias "thinBasic_CheckMinus_Optional" () As Long
Declare Function thinBasic_CheckMult_Optional Lib "thinCore.DLL" Alias "thinBasic_CheckMult_Optional" () As Long
Declare Function thinBasic_CheckDiv_Optional Lib "thinCore.DLL" Alias "thinBasic_CheckDiv_Optional" () As Long
Declare Function thinBasic_CheckEOL_Optional Lib "thinCore.DLL" Alias "thinBasic_CheckEOL_Optional" () As Long
Declare Function thinBasic_GetUnknownToken Lib "thinCore.DLL" Alias "thinBasic_GetUnknownToken" (Optional ByVal AutoPutBack As Long) As String
'----------------------------------------------------------------------------
'----------------------------------------------------------------------------
Declare Function thinBasic_CheckEqualType_Mandatory Lib "thinCore.DLL" Alias "thinBasic_CheckEqualType_Mandatory" () As Long
%Equal_EQ = 1520& ' =
%Equal_PLUSEQUAL = 1521& ' +=
%Equal_MINUSEQUAL = 1522& ' -=
%Equal_MULTIPLYEQUAL = 1523& ' *=
%Equal_DIVIDEEQUAL = 1524& ' /=
%Equal_IDIVIDEEQUAL = 1525& ' \=
%Equal_CONCEQUAL = 1526& ' &=
%Equal_POINTEQUAL = 1527& ' .=
'----------------------------------------------------------------------------
Variables:
'----------------------------------------------------------------------------
'thinBasic_GetVariableNumberDirect
'----------------------------------------------------------------------------
'
' Returns the value of a variable giving its ptr and it abs position
'----------------------------------------------------------------------------
Declare Function thinBasic_GetVariableNumberDirect _
LIB "thinCore.DLL" _
Alias "thinBasic_GetVariableNumberDirect" _
( _
ByVal VariablePtr As Long , _
ByVal VariableAbsPos As Long _
) As Ext
'----------------------------------------------------------------------------
'thinBasic_ChangeVariableUDTDirect
'----------------------------------------------------------------------------
' See also thinBasic_VariableParse
'
' Change a variable using direct variable pointer's data returned by
' thinBasic_VariableParse. This will ensure to work also with arrays
'----------------------------------------------------------------------------
Declare Function thinBasic_ChangeVariableUDTDirect _
Lib "thinCore.DLL" _
Alias "thinBasic_ChangeVariableUDTDirect" _
( _
ByVal VariablePtr As Long , _
ByVal VariableAbsPos As Long , _
ByVal lValString As String _
) As Long
Other:
'----------------------------------------------------------------------------
'thinBasic_ScriptIsObuscated
'----------------------------------------------------------------------------
'----------------------------------------------------------------------------
Declare Function thinBasic_ScriptIsObfuscated Lib "thinCore.DLL" Alias "thinBasic_ScriptIsObfuscated" () As Long
'----------------------------------------------------------------------------
Tracing:
'----------------------------------------------------------------------------
'Trace Handling
'----------------------------------------------------------------------------
'----------------------------------------------------------------------------
' TRACE Equates
'---What to ask for
%TRACE_What_SourcePtr = 1&
%TRACE_What_StackLevel = 10&
%TRACE_What_IFLevel = 20&
%TRACE_What_SourceFullPath = 30&
'---Error codes
%TRACE_Error_NotPossible_Obfuscated = 1&
%TRACE_Error_InstallHandle_Null = 200&
%TRACE_Error_InstallHandle_AlreadyInstalled = 201&
'----------------------------------------------------------------------------
'thinBasic_ITrace_GetValue
'----------------------------------------------------------------------------
'
'
'
'
'----------------------------------------------------------------------------
Declare Function thinBasic_ITrace_GetValue _
Lib "thinCore.dll" _
Alias "thinBasic_ITrace_GetValue" _
( _
ByVal lWhat As Long , _
Optional ByVal sWhat As String , _
ByVal lRet1 As Long Ptr , _
ByVal lRet2 As Long Ptr , _
ByVal sRet1 As String Ptr _
) As Long
'----------------------------------------------------------------------------
'thinBasic_ITrace_InstallHandle
'----------------------------------------------------------------------------
'
'
'
'
'----------------------------------------------------------------------------
Declare Function thinBasic_ITrace_InstallHandle _
Lib "thinCore.dll" _
Alias "thinBasic_ITrace_InstallHandle" _
( _
ByVal fHandle As Long _
) As Long
'----------------------------------------------------------------------------
'----------------------------------------------------------------------------
'thinBasic_StackGetCurrent
'----------------------------------------------------------------------------
' Returns the current script stack level.
' 1 = Global, 2 = next function executed, 3 = ...
'----------------------------------------------------------------------------
Declare Function thinBasic_StackGetCurrent _
Lib "thinCore.dll" _
Alias "thinBasic_StackGetCurrent" _
( _
) As Long
'------------------------------------------------------------------------------
'----------------------------------------------------------------------------
'thinBasic_StackGetList
'----------------------------------------------------------------------------
' Returns a string containing the names of the current nesting stack levels
' As a minimum this function will return one string containing "GLOBAL"
'----------------------------------------------------------------------------
Declare Function thinBasic_StackGetList _
Lib "thinCore.dll" _
Alias "thinBasic_StackGetList" _
( _
Optional ByVal sSep As String _
) As String
'----------------------------------------------------------------------------
Errors:
'----------------------------------------------------------------------------
'thinBasic_ErrorFlag
'----------------------------------------------------------------------------
' Returns a value different from 0 if a runtime error occurred
'----------------------------------------------------------------------------
Declare Function thinBasic_ErrorFlag Lib "thinCore.DLL" Alias "thinBasic_ErrorFlag" () As Long
'----------------------------------------------------------------------------
'thinBasic_ErrorFree
'----------------------------------------------------------------------------
' Returns -1 if there thinBasic is not under runtime error state
'----------------------------------------------------------------------------
Declare Function thinBasic_ErrorFree Lib "thinCore.DLL" Alias "thinBasic_ErrorFree" () As Long
'----------------------------------------------------------------------------
'----------------------------------------------------------------------------
'thinBasic_ErrorUserConfirmed
'----------------------------------------------------------------------------
' Returns -1 if, after an error, user has confirmed the dialog
'----------------------------------------------------------------------------
Declare Function thinBasic_ErrorUserConfirmed Lib "thinCore.DLL" Alias "thinBasic_ErrorUserConfirmed" () As Long
'----------------------------------------------------------------------------
%ERR__PREPARSER_DirectiveNotSupported = 800&
%ERR__PREPARSER_ScriptVersionRequest = 820&
%ERR__INTERNAL_RETURNMAINTYPE = 900&
%ERR__INTERNAL_DECRIPTION = 910&
%ERR__INTERNAL_UDTBUFFER_SHORT = 915&
%ERR__INTERNAL_RETURNNONE_NOCODEPTR = 921&
%ERR__INTERNAL_RETURNNUMBER_NOCODEPTR = 922&
%ERR__INTERNAL_RETURNSTRING_NOCODEPTR = 923&
%ERR__CLASS_NEW_NOINDEXALLOWED = 5010&
%ERR__CLASS_NEW_DIFFERENTCLASS = 5015&
%ERR__CLASS_NEW_NOCLASS = 5020&
%ERR__CLASS_NEW_EXPECTED_NEW = 5025&
%ERR__CLASS_NOT_INIT_WITH_NEW = 5030&
%ERR__CLASS_METHODPROPERTY_NOTFOUND = 5100&
%ERR__TRACE_STOP_BY_USER = 11000&
%ERR__OBFUSCATION_FILENOTVALID = 12000&
%ERR__COM_GENERIC = 30000&
Classes:
'----------------------------------------------------------------------------
'thinBasic_Class_Add
'----------------------------------------------------------------------------
' Add a new class to thinBasic Core Engine
'----------------------------------------------------------------------------
Declare Function thinBasic_Class_Add _
Lib "thinCore.dll" _
Alias "thinBasic_Class_Add" _
( _
ByVal sClassName As String , _ '---Name of the Class to be created
ByVal pClassFunc As Long _ '---Pointer to a class function that will handle calls to methods
) As Long
'----------------------------------------------------------------------------
'----------------------------------------------------------------------------
'thinBasic_Class_AddMethod
'----------------------------------------------------------------------------
' Add a method to a class previously created with thinBasic_Class_Add
'----------------------------------------------------------------------------
Declare Function thinBasic_Class_AddMethod _
Lib "thinCore.dll" _
Alias "thinBasic_Class_AddMethod" _
( _
ByVal pClass As Long , _ '---Poiter to a class. This is the value returned by thinBasic_Class_Add
ByVal sMethodName As String , _ '---Name of the Class to be created
ByVal MethodReturnType As Long , _
ByVal pMethodFunc As Long _ '---Pointer to a method function that will handle method execution
) As Long
'----------------------------------------------------------------------------
%Class_Action_None = 0?
%Class_Action_Get = 1?
%Class_Action_Set = 2?
%Class_Action_Constructor = 100?
%Class_Action_Destructor = 110?
'----------------------------------------------------------------------------
'thinBasic_Class_AddProperty
'----------------------------------------------------------------------------
' Add a property to a class previously created with thinBasic_Class_Add
'----------------------------------------------------------------------------
Declare Function thinBasic_Class_AddProperty _
Lib "thinCore.dll" _
Alias "thinBasic_Class_AddProperty" _
( _
ByVal pClass As Long , _ '---Poiter to a class. This is the value returned by thinBasic_Class_Add
ByVal sPropertyName As String , _ '---Name of the Class to be created
ByVal PropertyReturnType As Long , _
ByVal PtrToPropertyFunction As Long _ '---Pointer to a method function that will handle method execution
) As Long
Thanks,
Petr
D.J.Peters
20-05-2013, 19:17
It's in the zip file now.
thank you
Joshy
By the way classes in the SDK means thinBasic or PowerBasic classes ?
Petr Schreiber
20-05-2013, 19:39
Whoa,
great!
Regarding the classes - I think what works now for sure is wrapping of COM objects, I did it from PowerBASIC during my tests.
I remember I talked with Eros about possibility to define objects using own allocations (to make it independent on COM), but I am not sure if it is possible at the moment. I will try to experiment with it and will let you know.
Petr
Petr Schreiber
20-05-2013, 20:31
Okay,
so both is possible: COM (better for writing in PowerBASIC) and custom allocations too (universal, any language).
I prepared example of both approaches for you and others in separate thread:
MyClass & MyClassCOM - simple demo of creating module class (http://www.thinbasic.com/community/showthread.php?t=12117)
Petr
thank you D.J.Peters (http://www.thinbasic.com/community/member.php?u=974) for the FreeBasic SDK update, btw I love your borg avatar. :)
D.J.Peters
21-05-2013, 11:18
The MainType for boolean and integer both are defined as 2
Is this right i mean bool and int are both 16 bit ?
why are all main and sub types double defined i mean with VAR_ in front ?
Joshy
const MainType_IsNumber As Long = 20
const VarMainType_IsNumber As Long = MainType_IsNumber
const VarMainType_IsAsciiZ As Long = 25
const MainType_String As Long = 30
const MainType_IsString as long = MainType_String
const VarMainType_IsString As Long = MainType_String
const MainType_GUID as long = 40
const MainType_IsGUID as long = MainType_GUID
const MainType_Variant As Long = 50
const MainType_IsVariant as long = MainType_Variant
const VarMainType_IsVariant As Long = MainType_IsVariant
const MainType_UDT As Long = 60
const MainType_IsUDT as long = MainType_UDT
const MainType_PTR as long = 70
const MainType_IsPTR as long = MainType_PTR
const MainType_Object as long = 80
const MainType_IsObject as long = MainType_Object
const MainType_Class as long = 90
const MainType_IsClass as long = MainType_Class
const SubType_Byte As Long = 1
const VarSubType_Byte As Long = SubType_Byte
const SubType_Integer As Long = 2
const VarSubType_Integer As Long = SubType_Integer
const SubType_Boolean as long = 2
const SubType_Word As Long = 3
const VarSubType_Word As Long = SubType_Word
const SubType_DWord As Long = 4
const VarSubType_DWord As Long = SubType_DWord
const SubType_Long As Long = 5
const VarSubType_Long As Long = SubType_Long
const SubType_Quad As Long = 6
const VarSubType_Quad As Long = SubType_Quad
const SubType_Single As Long = 7
const VarSubType_Single As Long = SubType_Single
const SubType_Double As Long = 8
const VarSubType_Double As Long = SubType_Double
const SubType_Currency As Long = 9
const VarSubType_Currency As Long = SubType_Currency
const SubType_Ext As Long = 10
const VarSubType_Ext As Long = 10
const SubType_AsciiZ As Long = 25
const SubType_String as long = MainType_String
const VarSubType_Variant As Long = MainType_Variant
ReneMiner
21-05-2013, 11:41
Yes
Uses "CONSOLE"
Dim myBoolYes As Boolean = TRUE
Dim myBoolNo As Boolean ' = FALSE
Dim myInteger As Integer = 123
PrintL "myBoolYes"
VarInfo(VarPtr(myBoolYes), SizeOf(Boolean))
PrintL "myBoolNo"
VarInfo(VarPtr(myBoolNo), SizeOf(Boolean))
PrintL "myInteger"
VarInfo(VarPtr(myInteger), SizeOf(Integer))
WaitKey
Sub VarInfo(ByVal pVar As DWord, ByVal sizeVar As Long )
Local sContent As String
Local i As Long
PrintL " Len =" + Str$(SizeVar)
For i = sizeVar - 1 To 0 Step -1
' ordered from back to front- they are flipped in memory...
sContent += Hex$(Peek(pVar + i), 2) + " "
Next
PrintL " Content =" + sContent
PrintL
End Sub
D.J.Peters
21-05-2013, 11:52
Hello ReneMiner
Thanx for the code I know how to get the size of any data i'm not a beginner :-)
My question is more SDK interpreter relevant.
If you define for all kinds of data types ID's
this ID's should be unique (normally) independent from its size in memory.
for example long and dword are the same size in memory but long is signed and dword are unsigned
this is why dword and long has different ID's
integer and boolean are the same size in memory but boolean are unsigned and integer are signed
both are defined as 2
from my point of view boolean should have it's own unique ID
You know what my bad english means ?
Joshy
ReneMiner
21-05-2013, 11:58
Help says:
tB-Version 1.6.0.4
Added BOOLEAN data type. It is internally managed exactly like INTEGER but it plays a role in VARIANT variables.
In VARIANT variables INTEGERs and BOOLEANs value are both stored in an INTEGER class shared space but internally their type is different. Some COM interfaces need a BOOLEAN type.
More Info maybe in help: thinBasic language (http://www.thinbasic.com/community/thinbasiclanguage.htm) > Data types and variables (http://www.thinbasic.com/community/variables.htm) > Variant variables
sorry that colorful copy&paste-thing from help...
Charles Pegge
21-05-2013, 12:21
Yes, it appears to be so. thinBasic derives its definition of integer from PowerBasic. ie: 16 bit signed integer. There is no formal boolean type, so integers are used as a substitute.
However I notice that in the Windows API, a boolean is the same size as INT (32 bits) within a typedef, though only the first bit is significant.
http://msdn.microsoft.com/en-us/library/windows/desktop/aa383751(v=vs.85).aspx
Thanks Joshy and Petr the FB-SDK update.
I incorporated the ascii_to_float / float_to_ascii routines into Oxygen's run-time-libraries. With low level access, all values are passed and returned on the FPU stack, avoiding any loss of precision due to 'double' intermediaries.
........................................
ReneMiner
25-03-2022, 02:09
i looked once again into fb - after a while - many years ago i tried to use it as programming language - but it was no fun.
Now, after a lot of experimenting using powerbasic with all the headers of José Roca, the cWindow-class, his csed etc. and a look again into fb i was surprised. When it needed always very long until freebasic made some significant moves forward and i see now what José has contributed there - unbelievable! not only all the stuff that you know that was present in powerbasic but a lot more.
It's somehow as if powerbasic was integrated to freebasic (both very much derive from the same "basic" Basic languages that were there in the late 1980s.
But since powerbasic is no more improving and no more bugfixes nor updates are to await and since José ported all his works into fb - including anything you could think of (tools, templates, hundreds of samples, hundreds of headers, wrappers and workarounds to avoid running into faulty code of the OS - convince me to change the equipment and i would like to use fb to create one or the other thinbasic module...
But the thincore.bi is a bit ... overaged. And i remember there was some hassle using strings into both directions but since main-process and dll can share the same memory i would in any case prefer to pass the data just using pointers to heap or hash instead of fighting with fb's zStrings (seems global heap that is locked, using tb-heap-functions on fb-zstring crashed as far as i remember.
Now the PB-thincore.inc provides an arsenal of shared hash-functions which is probably solving all issues when it comes to strings and it has the advantage that we can use a continous row of keys as "key_0001", key_0002... and continue receive function-results by (ab)using a callback as invoker.
I would appreciate a few more examples that describe the use of some sdk-functions ,
for example there is a constructor and a destructor-method on module classes (_Create and _Destroy) i can declare new methods and emulate subs and functions even with a wild approach of passing keywords and parameters in a mixture that you would shake your head if yoi would see that.
But there are also properties that i can declare- so i never saw an example and i am not sure how properties are to create since i know from other languages these properties have Let, Get and Set to initialize, retrieve or alter the values of a property. if i have a property "Size" how is it initialized and how do i create the properties as up to 3 functions like
' within function LoadLocalSymbols :
thinBasic_Class_AddProperty(pClass,"_Let_Margin", %thinBasic_ReturnNone, CODEPTR(cDag_Let_Margin)
thinBasic_Class_AddProperty(pClass,"_Get_Margin", %thinBasic_ReturnCodeLong, CODEPTR(cDag_Get_Margin)
thinBasic_Class_AddProperty(pClass,"_Set_Margin", %thinBasic_ReturnNone, CODEPTR(cDag_Set_Margin))
or do i have toi use "Margin_SET", "Margin_LET", "Margin_GET" or is it all in one?
as just
thinBasic_Class_AddProperty(pClass,"_property_Column", %thinBasic_ReturnCodeLong, CODEPTR(cDag_property_Column))
And is a property here limited to ONE VALUE ONLY ? (width, separate height...) or can it be a whole virtual udt as
$enumProperty_Size="Int32(Width,Height;Current,Min,Max)"
lVal(2,3) As Long
And mentioning virtual - can i use thinBasic_AddVariable to create a variable inside of a tb-scriptfunction that is placed at some memory within the module?
If it can do this -will that work also placing an udt virtually upon some position or is there a function that can do something like that?
And can i declare the win32-api-heap-functions within the module to use the same heap as the script functions will do? if yes- is it process heap or private heap
what we use in the sscripts?
just one more:
thinBasic_DeclareFunction
is it to use for
Declare Function myModulefunction Lib "thismodule.dll" Alias "myModFunc" ([parameters])
or to wrap api-functions to make these available in thinBasic scripts?
Or to make a thinbasic corefunction available to the module?
hello ReneMiner
the FreeBasic manual has a good amount of information, it also includes tutorials you can download the manual from https://users.freebasic-portal.de/stw/builds/ or you can read the FBWiki https://www.freebasic.net/wiki/ProPgProperties
ReneMiner
03-04-2022, 08:48
i have plenty of docs for fb, thanks. My questions were more about tb and how to use tb-sdk-functions with fb