PDA

View Full Version : ThinBASIC COM Server



RobertoBianchi
28-07-2008, 12:44
Please find in the attached file the first experimental version of ThinBASIC COM server, it supports the dual interface so you can use it for launch of ThinBASICs’ script from .VBS script, .JS script and VBA as well using the Dispatch interface from other languages (please see the TBCOMSRV.INC for use it from Power Basic).

Warning: this is a trial version that will expire at December 31, 2008.

There are the four methods available, here is a brief syntax explanation of them:

Initialize() Method
The Initialize method initializes the interpreter for use by client application (for example a not ThinBASIC script).

Syntax
Initialize(sUser As String, sKey As String, Flag As Long, hWnd As long, hInstance As Long)

Parameters
sUser A valid user name, for trial pass "EveryOne"
sKey A valid key, fro trial pass "TrialVersion"
Flag Not used, pass 0
hWnd Handle to the owner window. If no owner window pass 0
hInstance Handle to application instance. If no instance pass 0

Run() Method
The Run method executes a ThinBASIC's script.

Syntax
Run(sScript As String, sCmdLine As String, Options As Long)

Parameters
sScript The ThinBASIC's Script to execute
sCmdLine Command line to pass to the script *
Options Not used, pass 0

* Actually this parameter isn't available

Free() Method
The Free release the interpreter and close all open resources.

Syntax
Free()

Parameters
This method has no parameters

DisplayInfo() Method
The DisplayInfo method display information about the COM server.
This method is also useful to check if the COM server is configured properly.

Syntax
DisplayInfo()

Parameters
This method has no parameters

The zip file also include some exalmples files (VBS, JS and Excel).

How use it:
You should copy the ThinBASIC.DLL file in the ThinBASIC’s installation root (C:\THINBASIC for example), open the command prompt then go to the ThinBASIC installation root and run this command: regsvr32 ThinBASIC.dll.
Now you are ready to use and test the COM Server.

As usual your feedbacks and suggestions are welcome.

Thank you very much and best regards,
Roberto

ErosOlmi
28-07-2008, 13:16
Hi Roberto,

what a great news!
I supppose this can open a big new development area.

Thanks for this preview.
Eros

Just a little note: the script you are using as example is not existing. You should execute a script like:
C:\thinBasic\SampleScripts\General\Speed\Test_Speed.tBasic
that should be present in all thinBasic installation (if thinBasic has being installed under C:\thinbasic\ directory)

RobertoBianchi
28-07-2008, 14:13
Updated with an existing ThinBASIC's script, sorry for the inconvenience.

Roberto

Petr Schreiber
28-07-2008, 15:11
Hi Roberto,

thanks a lot for this new feature, seems like powerful thing!

I moved DLL to path where thinBasic.exe is, registered the library and modified paths in VBS and JS scripts.
Only trouble is, that for successful execution I have to place VBS and JS in same directory with thinBasic. Is it correct?

I did not succeeded in Excel, can be because of that path complication, will investigate further.


Thanks a lot,
Petr

RobertoBianchi
28-07-2008, 16:01
Hi Petr,

just for now the server has a limitation that can run script only on the same disk, this is due to the algorithm used for discovery the interpreter's path.
For example if you have ThinBASIC installled on F:\ThinBASIC you could run scripts located in F:\ or F:\MyFolder1\MyScript\Test but not in C:\.
If you run the TestTBCOMSRV.js from a variousness of locations it should tell you if it finds and where is the interpreter.

Thanks for your testing.

Ciao,
Roberto

Petr Schreiber
28-07-2008, 17:05
Hi Roberto,

thanks for the explanations!
But I think there is still some trouble

I have thinBasic installed here: E:\Util\ThinBasic\

When I run TestTBCOMSRV.js from there, it correctly reports that it found core library.
If I run it from E:\Util\ThinBasic\COMServerTest\, then I get report on attached screenshot.

Maybe the msgbox could contain some more info which could ease finding problems?


Petr

RobertoBianchi
28-07-2008, 18:42
Hi Petr,

I've updated the ZIP file, now if you have the ThinBASIC install path into the register the COM server should retrive and use for detect the interpreter.

Ciao,
Roberto

Petr Schreiber
28-07-2008, 20:02
Hi Roberto,

perfect job, all works now :)

One thing - in case I specify not existing script file, it makes GPF in Windows Based Script Host or something like that.


Petr

kryton9
28-07-2008, 23:10
Roberto, all the tests worked fine that I could test. I couldn't test the spreadsheet one as I don't have a spreadsheet app installed on this computer at the moment.
Thanks!

RobertoBianchi
29-07-2008, 09:24
Thanks to all!

Petr,

the GPF appears in Windows Based Script Host but it seems related to a lack of "sanity checks" into thincore.dll.
However we will see to do something on thinbasic.dll or thincore.dll.

Ciao,
Roberto

ErosOlmi
29-07-2008, 10:44
Roberto,

I will check in thinCore.dll what happen when the passed script is a not existing file.
I should have already managed it but I will double check again.

Ciao
Eros

ErosOlmi
29-07-2008, 16:49
Ok, I checked inside thinCore.dll

Problem is there and precisely inside the Dialog Box of the RuntimeError handling function, the dialog used to show runtime error info to the user.

Now I've fixed GPF but there is no dialog. This because RTE dialog is managed by an external DLL (thinRTE.dll) loaded dynamically when an error occurs. Now the loader of this dll is not able to find it because the main executable is not anymore thinBasic.exe but wScript.exe (in case of VBS) or other executable (in case of Excel files, js, ...)

What I'm thinking to do is to incorporate thinRTE.dll functionalities inside main thinBasic engine (thinCore.dll). In this way there will be one dll less and no dependancies.

I will check further in next days.

Regards
Eros

RobertoBianchi
29-07-2008, 17:58
Eros,

maybe it's better not touch thinRTE.dll and thinCore.dll, the important thing is having eliminated the GPF.
Instead we can add the script's existence check to the COM server and later fix the dynamic loading of RTE.
What do you think about?

Ciao,
Roberto

RobertoBianchi
30-07-2008, 15:13
Updated the TBCOMServer.zip attachement with a couple of scripts that show how run a script from a string variable.

Roberto

Petr Schreiber
30-07-2008, 17:17
Thanks Roberto,

worked well for me!
Just that different thinBasic install path on my PC forced me to update paths in test scripts manually.
Not anymore, script slave does the dirty job for me, see attachement :)


Petr

UPDATED

RobertoBianchi
30-07-2008, 17:35
Amazing, you are a high automated guy! ;)
I also like scripting because it can do a lot of otherwise annoying and repetitive works.

Roberto.

RobertoBianchi
31-07-2008, 12:51
Updated the TBCOMServer.zip attachement with a Power Basic example that show how run a script from a PB executable.

Regards,
Roberto

Petr Schreiber
31-07-2008, 15:23
Thanks Roberto,

worked ok for my PB.
I think the LET <objVar>, SET <objVar> are optional, at least when I put out those keywords, it worked too.
According to help file, SET has been replaced with LET ... and LET is optional :)


Petr

RobertoBianchi
31-07-2008, 16:15
Petr,

thanks for the info, updated again for reflecting your suggestions.

Ciao,
Roberto