Hi Joe,
thanks for your suggestion, I will check what I can do.
thinBasic Core engine is written using Power Basic compiler and should definitely possible to develop COM components using it.
Eros
I would like to use thincore.dll with Visual Basic 6.0
I looked in the \thinBasic\sdk\sdk.zip,
and found thinBasic BASIC SDK\PB,
which I could use as a reference for embedding in VB6.
Before I do so,
I was wondering if anyone has already created a thinBasic SDK for VB6,
and would be interested in sharing it.
My end goal is to create a COM DLL,
which I can use with Visual Basic 6.0,
Visual FoxPro 9.0,
and other COM-callable languages.
I occasionally use AutoIt, which comes with AutoItX, a DLL/COM control.
Perhaps a future addition to thinBasic could be something similar,Add AutoIt features to your favorite programming and scripting languages!
Also features a C# assembly and PowerShell CmdLets.
maybe a thinBasicX COM DLL,
which is what I am hoping to do with VB6 and thincore.dll
Regards and Thanks,
Joe
Hi Joe,
thanks for your suggestion, I will check what I can do.
thinBasic Core engine is written using Power Basic compiler and should definitely possible to develop COM components using it.
Eros
www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000
I'm having issues in getting thinCore.dll working with Visual Basic 6.0
The program quits when thinBasic_Run is called.Option Explicit ' Microsoft Visual Basic 6.0 (SP6) ' Windows 10 [Version 10.0.19045.3693] 22H2 ' ' AddIn Used - Visual Basic 6 IDE Linker Addin ' - LinkSwitches /SUBSYSTEM:CONSOLE ' Ref: https://www.vbforums.com/showthread.php?866321-VB6-IDE-Linker-AddIn ' ' Ref: https://github.com/ErosOlmi/ThinBASIC_On_GitHub/blob/master/Lib/thinCore.INC ' thinCore.dll is in my App.Path folder Declare Function thinBasic_Init Lib "thinCore.dll" (ByVal hWnd As Long, _ ByVal cInstance As Long, _ ByVal sKey As String) As Long Declare Function thinBasic_Release Lib "thinCore.dll" (ByVal hScript As Long) As Long Declare Function thinBasic_Run Lib "thinCore.dll" (ByVal hScript As Long, _ ByVal sBuffer As String, _ ByVal BufferType As Long, _ Optional ByVal Options As Long, _ Optional ByVal DebugMode As Long, _ Optional ByVal LogMode As Long, _ Optional ByVal ObfuscateMode As Long, _ Optional ByVal CallingProgram As Long, _ Optional ByVal DependancyMode As Long) As Long Dim Con As New Console Dim hScript As Long Dim sScript As String Dim hRun As Long Const thinBasic_BufferType_IsFile = 0 Sub Main() On Error GoTo CatchError sScript = "E:\Documents\vb6\ThinBasic\Alert.tBasic" Con.OutStd ("App.hInstance = " + Str$(App.hInstance)) Con.OutStd ("App.Path = " + App.Path) Con.OutStd ("Init") hScript = thinBasic_Init(0, App.hInstance, "") Con.OutStd ("Run") hRun = thinBasic_Run(hScript, sScript, thinBasic_BufferType_IsFile, 1 Or 2, False, False, False, 1, False) 'Program quits here 'From IDE: Run-time error '0' 'From EXE: No error, Alert.tBasic is not run ' 'Output: 'App.hInstance = 4194304 'App.Path = E:\Documents\vb6\ThinBasic 'Init 'Run Con.OutStd ("Release") thinBasic_Release (hScript) Exit Sub CatchError: Con.OutStd (Err.Number) Resume Next Return End Sub
I have probably missed something in the translation of the Declare functions.
Constructive assistance would be appreciated.
Joe
Sorry Joe, I forgot about this thread.
If you change
tothinBasic_Init(0, App.hInstance, "")
should workthinBasic_Init(0, App.hInstance, "thinbasic")
But there are other problems if you try to execute your script again using current thinCore.dll
I'm making some fix to:
- thinBasic_Init
- thinBasic_Run
- thinBasic_Release
in order to make it working as an engine
Attached a VB6 example with an update thinCore.dll that works better but still some problems.
I will work on this next days and will be back.
Last edited by ErosOlmi; 16-03-2024 at 11:50.
www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000
Thanks Eros,
Your example works as described.
I'm now trying to figure out how to modify a variable from VB6.
For example;
Note I have created a Long variable called "test",Dim sScript As String Dim hRun As Long Dim test As Long test = 1957 Const thinBasic_BufferType_IsFile = 0 Const thinBasic_BufferType_IsScript = 1 On Error GoTo CatchError sScript = txt_thinBasicSourceCode.Text If Len(sScript) Then hScript = thinBasic_Init(0, App.hInstance, "thinbasic") If hScript = 0 Then hRun = thinBasic_Run(hScript, sScript, thinBasic_BufferType_IsScript, 1 Or 2, False, False, False, 1, False) 'thinBasic_Release (hScript) End If Debug.Print thinBasic_VariableExists("test") Debug.Print test Else MsgBox "Please type some thinBasic code into textbox" End If
and assigned a value of 1957.
thinBasic_VariableExists("test") returns 1 if the variable exists, which it does.
In the text box, if I add;
...before the MsgBox 0, sMsg, 1960 is returned in the MsgBox.long Test = 1960 sMsg += Str(Test)
The help file has a blank page for thinBasic_VariableExists, along with all of the other thinBasic_ functions.
I was just guessing what the thinBasic_ functions do,
but not being very successful.
I did a review of \thinBasic\Lib\thincore.inc,
but still having issues in understanding.
How would I return the test variable,
with a value of 1960, to VB6?
Joe
After a restful sleep, I've done some more research.
I'm thinking that I have to use thinBasic_LoadSymbol
I've declared it in VB6 as follows;
So, if I want to use thinBasic to increment a number from VB6 by 1,Declare Function thinBasic_LoadSymbol Lib "thinCore.DLL" (ByVal SymbolName As String, ByVal ReturnCode As Long, ByVal FunctionOrSubPointer As Long, Optional ByVal ForceOverWrite As Long) As Long
in VB6 the flow would go something like this...
VB6AddOne will be my new "keyword" (function) that I call in VB6.thinBasic_LoadSymbol "VB6AddOne", thinBasic_ReturnNumber, VarPtr(TBAddOne(20))
TBAddOne will be my function in thinBasic.
I pass the number 20 in TBAddOne,
which will increment by 1,
and return 21.
CODEPTR is not recognized by VB6,
so I am using VarPtr.
Not sure if this is the proper replacement.
In the text box,
I add the following function for thinBasic;
As shown in attachment, I've got issues.function TBAddOne(theTest) as long function = theTest + 1 end function
image.png
Constructive guidance would be appreciated.
Joe
Last edited by Joe Caverly; 17-03-2024 at 17:20.
Hi Joe,
will prepare an example next days.
In the meantime refer to thinCore.inc file here https://github.com/ThinBASIC/module_...r/thinCore.inc that shows thinCore.dll exported functionalities you can use.
thinBasic_LoadSymbol is used to add new keywords inside thinBasic. You need to have a compiled Sub/Function an map it in thinBasic passing its Sub/Function pointer.
Then you will be responsible to parse thinBasic source code. This is a little complex but I can show you next days
I do not know if VB6 has the possibility to have a pointer to a Sub/Function like CodePtr
Anyway, to add a new variable use thinBasic_AddVariable
You can just create a variable initializing it value and also create a variable that uses a memory area of your own VB6 variable passing optional parameter VarMemPtr
Example for numeric (%VarSubType_Long = 5, refer to https://github.com/ThinBASIC/module_...r/thinCore.inc )
call this before thinBasic_Run to add a variable of type LONG called MyLog with value 1234
thinBasic_AddVariable("MyLong", "", 1234, %VarSubType_Long)
call this before thinBasic_Run to add a variable of type LONG called MyLog that share the same memory area of your VB6 MyLongInVB6 LONG variable
Dim MyLongInVB6 as long thinBasic_AddVariable("MyLong", "", 0, %VarSubType_Long, VarPtr(MyLongInVB6 ))
www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000
Just as a hint: put an invisible (OUT OF VISIBLE RANGE ONLY) Textbox on your vb-form. Save the hwnd of it simply as Hex$ for a filename in an empty subfolder of your project. From thinbasic send
Dword Htext =val("0x" & SHELL_CAPTUREOUTPUT("CMD /C DIR /A:-D /B " & app_scriptpath & "the_folder\*.*", "", %Sw_hide,10))
Since its from same process you can use STRING sNUMERICS = mkbyt$(49,00,57,00,53,00,55,00,00)
Thats "1957" in widechar with a terminating zero
Then sendmessage(htext, %em_settext, sNumerics,-1)
No more sure if it was -1 but it should do something as redraw or refresh the control.
In vb your form should have a sub textbox1_textchange() that should fire up. Use val(textbox1.text) ...
Last edited by ReneMiner; 18-03-2024 at 14:49.
I think there are missing some Forum-sections as beta-testing and support
Here attached a VB6 project in which I've injected a thinBasic variable connected to a VB6 variable so calling VB program can share variables with thinBasic script at runtime.
The script evaluate a math expression over X with X from a min to a max with step
ATTENTION: I've created a new thinCore.dll version for this script.
There is a a new exported function called thinBasic_AddVariable_VB
I did this because most of thinBasic API interfaces use EXTENDED numeric data type and EXTENDED (10 bytes) are not supported in VB6
So I developed thinBasic_AddVariable_VB that accepts Doubles
Hope this can help.
Last edited by ErosOlmi; 18-03-2024 at 22:33.
www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000
Thanks Eros!
I've tried your sample out,
and it works as documented.
I will do some more testing over the next few days.
Joe
Bookmarks