Joe Caverly
09-01-2024, 14:45
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
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
Works as it should.
So far, so good.
Here's another .vbs that I am converting to .tbasicc
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
This .vbs code works as it should, that is, it allows Registration-Free use of COM DLLs.
Here is my conversion to .tbasicc
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
...which returns...
clsMath not created
Why is clsMath not being set to a COM object?
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.php?894955-vbRichClient-(RC6)-amp-RC6-Widgets-Docs-UPDATED!
Ref: https://www.vbforums.com/showthread.php?897817-Registry-Free-Object-Instantiation-using-DirectCOM-amp-RC6
Ref: https://www.vbrichclient.com/en/Downloads.htm
Thanks from Joe
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
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
Works as it should.
So far, so good.
Here's another .vbs that I am converting to .tbasicc
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
This .vbs code works as it should, that is, it allows Registration-Free use of COM DLLs.
Here is my conversion to .tbasicc
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
...which returns...
clsMath not created
Why is clsMath not being set to a COM object?
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.php?894955-vbRichClient-(RC6)-amp-RC6-Widgets-Docs-UPDATED!
Ref: https://www.vbforums.com/showthread.php?897817-Registry-Free-Object-Instantiation-using-DirectCOM-amp-RC6
Ref: https://www.vbrichclient.com/en/Downloads.htm
Thanks from Joe