I can have a surprise in next thinBasic update.
Where can I found JLCUtils.dll file?
I have a number of VBScripts that are using vbRichClient RC6
I am hoping that I can convert the VBScripts using the vbRichClient RC6 to thinBasic.
Here I have converted a .VBS using the vbRichClient RC6 to .tbasicc
Works as it should.uses "Console" dim rc6 as iDispatch printl "Creating rc6.cActiveScript object" rc6 = NewCom("rc6.cActiveScript") if IsComObject(rc6) Then rc6.ExecuteStatement("function Times2(theNumber):Times2=theNumber*2:end function:Product=Times2(10)") printl rc6.Eval("Product") rc6 = Nothing else printl "rc6 not created" end if
So far, so good.
Here's another .vbs that I am converting to .tbasicc
This .vbs code works as it should, that is, it allows Registration-Free use of COM DLLs.Dim rc6 'as Object Const theDLL = "E:\Documents\vb6\DirectCOM\bin\JLCUtils.dll" Const theClass = "clsMath" Set rc6 = CreateObject("rc6.cRegFree") Set CScript = New Console Set clsMath = rc6.GetInstance(theDLL,theClass) CScript.Echo clsMath.ppp(6.59) Set clsMath = Nothing Set rc6 = Nothing Class Console Private fso Private stdout Private stderr Private Sub Class_Initialize() Set fso = CreateObject("Scripting.FileSystemObject") Set stdout = fso.GetStandardStream(1) Set stderr = fso.GetStandardStream(2) End Sub Public Sub Echo(theArg) stdout.WriteLine theArg End Sub Private Sub class_Terminate() Set stderr = Nothing Set stdout = Nothing Set fso = Nothing End Sub End Class
Here is my conversion to .tbasicc
...which returns...Uses "Console" Uses "Trace" Const theDLL = "E:\Documents\vb6\DirectCOM\bin\JLCUtils.dll" Const theClass = "clsMath" dim rc6 as iDispatch Dim clsMath as iDispatch rc6 = NewCom("rc6.cRegFree") if IsComObject(rc6) Then clsMath = rc6.GetInstance(theDLL,theClass) if IsComObject(clsMath) then Printl clsMath.ppp(6.59) clsMath = Nothing else printl "clsMath not created" end if rc6 = Nothing else printl "rc6 not created" end if
Why is clsMath not being set to a COM object?clsMath not created
Note that it sets rc6 to a COM object.
How do I go about getting a reference to the rc6.GetInstance method,
as I do in VBScript?
Ref: https://www.vbforums.com/showthread....s-Docs-UPDATED!
Ref: https://www.vbforums.com/showthread....ectCOM-amp-RC6
Ref: https://www.vbrichclient.com/en/Downloads.htm
Thanks from Joe
I can have a surprise in next thinBasic update.
Where can I found JLCUtils.dll file?
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
JLCUtils.dll is just a simple COM Server that I made for testing.
You can download it from: https://drive.proton.me/urls/PXEWXB9GRW#yiZ1CvJ1L2bk
Link expires January 27, 2024
Thanks Eros.
Joe
thinBasic has an undocumented NEWCOM syntax that allows creation of iDispatch class objects without the need to register you DLL into the registry.
The only problem is that you need to know the ClassId of the class you want to use.
So there is no need to create an instance of rc6.cRegFree and use it to load you unregistered DLL JLCUtils.dll
Please try the following script and let me know.
uses "Console" Dim clsMath as iDispatch '---Class ID for clsMath class $CLSID_clsMath = "{41A25489-48D5-4941-B792-FF9B20D32025}" clsMath = NEWCOM CLSID $CLSID_clsMath LIB APP_SourcePath + "JLCUtils.dll" if IsComObject(clsMath) then Printl clsMath.ppp(6.59) clsMath = Nothing else printl "clsMath not created" end if printl "All done, press a key to end" WaitKey
Last edited by ErosOlmi; 23-01-2024 at 01:48.
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
Oh, wow!
I copied jlcutils.dll and your script (jlcutils.tbasicc) over to my R:\ drive.
Ran e:\thinbasic\thinbasicc.exe jlcutils.tbasicc
Started up process explorer,
and verified that it was using jlcutils.dll from my R:\ drive.
Indeed it is!
Thankyou very much for that!
Makes things much easier!
Joe
Yes, you can put your COM dll in any place, just refer to its full path after LIB in:
This syntax was an experiment I did many month ago but never really finished and documented.... NEWCOM CLSID sClassId LIB sLibName
I will do next thinBasic version
Also I will add in thinAir a TypeLibrary browser, a program I derived from a Josè Roca developer that developed it in Power Basic many ears ago.
It will help in understanding what's inside a COM DLL and get ClassIds of classes.
Last edited by ErosOlmi; 23-01-2024 at 02:05.
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
That's the one I use also;
tlb.jpeg
Mine is probably a bit old,
as I am using TypeLib Browser 5.0.1 from 2011
Joe
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 can now easily use all of the RC6 classes in thinBasic.
Here's the thinBasic method of using the RC6 ActiveScript Class,
without having the need to have the RC6.dll registered in Microsoft Windows...
Here's another, using the StringBuilder Class...uses "Console" 'uses "Trace" Dim clsActiveScript as iDispatch '---Class ID for cActiveScript class $CLSID_cActiveScript = "{0961ABDC-07AA-483B-ADA0-55D14A2DEDCE}" printl APP_SourcePath + "rc6.dll" 'These .dll files need to be in the same folder 'cairo_sqlite.dll 'DirectCOM.dll 'RC6.dll 'RC6Widgets.dll 'WebView2Loader.dll clsActiveScript = NEWCOM CLSID $CLSID_cActiveScript LIB "E:\Documents\vb6\RC6BaseDlls\rc6.dll" if IsComObject(clsActiveScript) then clsActiveScript.ExecuteStatement("function Times2(theNumber):Times2=theNumber*2:end function:Product=Times2(10)") printl clsActiveScript.Eval("Product") clsActiveScript.AddCode("function Times2(theNumber):Times2=theNumber*2:end function") printl clsActiveScript.Eval("Times2(15)") printl clsActiveScript.Eval("2023-1945") clsActiveScript = Nothing else printl "clsActiveScript not created" end if printl "All done, press a key to end" WaitKey
Joeuses "Console" Dim clsStringBuilder As iDispatch '---Class ID for cStringBuilder class $CLSID_cStringBuilder = "{8BF37C34-25F8-4605-BEF0-5069594FAA8C}" clsStringBuilder = NEWCOM CLSID $CLSID_cStringBuilder LIB "E:\Documents\vb6\RC6BaseDlls\rc6.dll" if IsComObject(clsStringBuilder) then clsStringBuilder.AddNl("One") clsStringBuilder.AddNl("Two") clsStringBuilder.AddNl("Three") printl clsStringBuilder.ToString clsStringBuilder = Nothing else printl "clsStringBuilder not created" end if printl "All done, press a key to end" WaitKey
Great!
Happy you can have your job done in thinBasic and happy you can help me to better develop this part of thinBasic that can have a lot more to give.
Will try to improve Newcom in order to have ClassName and not only ClassId for unregistered com server loaded directly from TypeLib DLL
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
Bookmarks